Skip to content

Instantly share code, notes, and snippets.

@cyberkov
Created March 18, 2015 14:42
Show Gist options
  • Save cyberkov/22bd39d117b0d914ef93 to your computer and use it in GitHub Desktop.
Save cyberkov/22bd39d117b0d914ef93 to your computer and use it in GitHub Desktop.
Read ILO IP and Subnet Mask from Dell Omreport
require 'facter'
require 'rexml/document'
dellilo_file = "/tmp/dellilo.cache.xml"
omreport = '/opt/dell/srvadmin/bin/omreport'
# When there is no file. create it.
unless FileTest.exists?(dellilo_file)
if FileTest.exists?(omreport)
# /opt/dell/srvadmin/bin/omreport system summary -fmt xml -outc /tmp/dellilo.cache.txt
Facter::Util::Resolution.exec("#{omreport} system summary -fmt xml -outc #{dellilo_file}")
end
end
if FileTest.exists?(dellilo_file) and File.size(dellilo_file) >= 100
xml = File.open(dellilo_file)
doc = REXML::Document.new(xml)
xml.close
data = [
[ 'ilo_ipaddress', "//EMPLANConfigObj/IPAddress" ],
[ 'ilo_netmask', "//EMPLANConfigObj/SubnetMask" ]
# [ 'ilo_dnsname', "//MOD_NETWORK_SETTINGS/DNS_NAME" ]
]
data.each do |fact_name, position|
element = REXML::XPath.first( doc, position)
Facter.add(fact_name) do
#setcode do element.attributes['VALUE'] end
setcode do
element.text
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment