Sha256: 5d080e7b97e995e7d7d7ec0677d4be52597c9375b23cc26e013ccc43860378d2

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

report do
  interfaces = {}
  ips = []

  Facter.value('network_interfaces').each do |iface|
    iface = iface.to_sym
    next if [:dummy0, :lo, :sit0].include?(iface)
    interfaces[iface] ||= {}

    mac = (Facter.value("macaddress_#{iface}").upcase rescue nil)
    mtu = (Integer(Facter.value("mtu_#{iface}")) rescue nil)

    interfaces[iface][:name] = iface
    interfaces[iface][:mac] = mac if mac
    interfaces[iface][:mtu] = mtu if mtu

    ips << Facter.value("ipaddress_#{iface}")

    addresses = [{
      :ip       => Facter.value("ipaddress_#{iface}"),
      :netmask  => Facter.value("netmask_#{iface}")
    }.reject{|k,v| v === nil }]

    interfaces[iface][:addresses] = addresses unless addresses.empty? or addresses.reject{|i| i.empty? }.empty?

  # LLDP autodiscovery
    switch = {
      :name        => Facter.value("lldp_switch_#{iface}"),
      :port        => Facter.value("lldp_port_#{iface}"),
      :port_name   => Facter.value("lldp_port_name_#{iface}"),
      :port_mac    => Facter.value("lldp_port_mac_#{iface}"),
      :ip          => Facter.value("lldp_management_ip_#{iface}"),
      :chassis_mac => Facter.value("lldp_chassis_mac_#{iface}"),
      :mfs         => Facter.value("lldp_mfs_#{iface}")
    }.reject{|k,v| v === nil }


  # Bonding configuration

  # slaves
    master = Facter.value("bonding_master_#{iface}")
    interfaces[iface][:master] = master if master

  # masters
    bond = {
      :arp_ip_target => Facter.value("bonding_arp_ip_target_#{iface}")
    }.reject {|k,v| v === nil }


  # conditionally add applicable subsections
    interfaces[iface][:switch]  = switch unless switch.empty?
    interfaces[iface][:bonding] = bond unless bond.empty?
  end

  property :network, {
    :@ip         => ips,
    :@interfaces => interfaces.values
  }
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
onering-report-plugins-0.0.39 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.38 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.37 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.36 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.35 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.34 lib/reporter/default/properties_network.rb