Skip to content

Instantly share code, notes, and snippets.

@trlinkin
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save trlinkin/e87e9d2c05268ebaa47a to your computer and use it in GitHub Desktop.

Select an option

Save trlinkin/e87e9d2c05268ebaa47a to your computer and use it in GitHub Desktop.
class SysInventory
def self.getInventory
unless @inventory
lshw = Facter::Util::Resolution.exec('lshw -json -quiet')
require 'json'
@inventory = JSON.parse lshw
end
@inventory
end
end
if SysInventory.getInventory
# I am so very very sorry for this
SysInventory.getInventory['children'].each do |c|
if c['id'] == 'core'
c['children'].each do |cc|
if cc['id'] == 'pci'
cc['children'].each do |ccc|
if ccc['class'] == 'bridge' and ccc['children']
ccc['children'].each do |dev|
if dev['class'] == 'network'
Facter.add("pci_eth_mac_#{dev['businfo']}") do
setcode do
dev['serial']
end
end
end
end
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment