7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/metadata/VmConfig/GetNativeCfg.rb', line 7
def self.new
lshwXml = AwesomeSpawn.run!("lshw", :params => ["-xml"], :combined_output => true).output
nodeHash = Hash.new { |h, k| h[k] = [] }
doc = MiqXml.load(lshwXml)
doc.find_match("//node").each { |n| nodeHash[n.attributes["id"].split(':', 2)[0]] << n }
hardware = ""
nodeHash["disk"].each do |d|
diskid = d.find_first('businfo').get_text.to_s
next unless diskid
sn = d.find_first('size')
next unless sn
busType, busAddr = diskid.split('@', 2)
if busType == "scsi"
f1, f2 = busAddr.split(':', 2)
f2 = f2.split('.')[1]
busAddr = "#{f1}:#{f2}"
else
busAddr['.'] = ':'
end
diskid = busType + busAddr
filename = d.find_first('logicalname').get_text.to_s
hardware += "#{diskid}.present = \"TRUE\"\n"
hardware += "#{diskid}.filename = \"#{filename}\"\n"
end
VmConfig.new(hardware)
end
|