Sha256: a28f28ee02d0cd7ab82f5c606cb5558ad855a410da9941baae565436019acb78

Contents?: true

Size: 1.99 KB

Versions: 27

Compression:

Stored size: 1.99 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}"),
      :speed        => Facter.value("lldp_speed_#{iface}"),
      :duplex       => Facter.value("lldp_duplex_#{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}"),
      :vlan         => Facter.value("lldp_vlan_#{iface}"),
      :tagged_vlans => Facter.value("lldp_tagged_vlans_#{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,
    :@sockets    => Facter.value('netstat')
  }
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
onering-report-0.6.13 lib/reporter/default/properties_network.rb
onering-report-0.6.12 lib/reporter/default/properties_network.rb
onering-report-0.6.11 lib/reporter/default/properties_network.rb
onering-report-0.6.10 lib/reporter/default/properties_network.rb
onering-report-0.6.9 lib/reporter/default/properties_network.rb
onering-report-0.6.8 lib/reporter/default/properties_network.rb
onering-report-0.6.7 lib/reporter/default/properties_network.rb
onering-report-0.6.6 lib/reporter/default/properties_network.rb
onering-report-0.6.5 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.65 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.64 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.63 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.62 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.61 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.60 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.59 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.58 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.57 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.56 lib/reporter/default/properties_network.rb
onering-report-plugins-0.0.55 lib/reporter/default/properties_network.rb