Last active
August 29, 2015 14:01
-
-
Save trlinkin/e87e9d2c05268ebaa47a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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