@@ -169,8 +169,23 @@ def parse_host_hardware(host, sys)
169169 end
170170
171171 def parse_host_guest_devices ( hardware , sys )
172- sys . io_adapters . each do |io |
173- next if io . udid . to_i == 65_535 # Skip empty slots
172+ sys . io_slots . each do |slot |
173+ io = slot . io_adapter
174+ next if io . nil? || io . udid . to_i == 65_535 # Skip empty slots
175+
176+ child_devices = slot . ior_devices . map do |port |
177+ persister . host_guest_devices . build (
178+ :hardware => hardware ,
179+ :uid_ems => port . location ,
180+ :device_type => "physical_port" ,
181+ :controller_type => "IO" ,
182+ :device_name => "Port" ,
183+ :location => port . location ,
184+ :model => port . description ,
185+ :address => port . macaddr . nil? ? port . wwpn : self . class . parse_macaddr ( port . macaddr ) ,
186+ :auto_detect => true
187+ )
188+ end
174189
175190 persister . host_guest_devices . build (
176191 :hardware => hardware ,
@@ -180,7 +195,8 @@ def parse_host_guest_devices(hardware, sys)
180195 :device_name => "Adapter" ,
181196 :location => io . dr_name ,
182197 :model => io . description ,
183- :auto_detect => true
198+ :auto_detect => true ,
199+ :child_devices => child_devices
184200 )
185201 end
186202 end
@@ -385,18 +401,9 @@ def parse_vm_guest_devices(lpar, hardware)
385401 build_ethernet_dev ( lpar , ent , hardware , "host ethernet adapter" )
386402 end
387403
388- # Physical adapters can be assigned to VIOSes and LPARs using IOMMU.
389- lpar . io_adapters . each do |io |
390- persister . guest_devices . build (
391- :hardware => hardware ,
392- :uid_ems => io . dr_name ,
393- :device_type => "physical_port" ,
394- :controller_type => "IO" ,
395- :device_name => "Adapter" ,
396- :location => io . dr_name ,
397- :model => io . description ,
398- :auto_detect => true
399- )
404+ # Physical adapters can be assigned to VIOSes and LPARs.
405+ lpar . io_slots . each do |slot |
406+ build_io_adapter ( slot . io_adapter , hardware ) unless slot . io_adapter . nil?
400407 end
401408 end
402409
@@ -406,6 +413,21 @@ def parse_lpar_guest_devices(lpar, hardware)
406413 build_ethernet_dev ( lpar , ent , hardware , "vnic" )
407414 end
408415 end
416+
417+ if collector . vfc_client_adapters . key? ( lpar . uuid )
418+ collector . vfc_client_adapters [ lpar . uuid ] . each do |vfc |
419+ persister . guest_devices . build (
420+ :hardware => hardware ,
421+ :uid_ems => vfc . uuid ,
422+ :device_name => vfc . dr_name ,
423+ :device_type => "physical_port" ,
424+ :controller_type => "client VFC adapter" ,
425+ :auto_detect => true ,
426+ :address => vfc . wwpns . join ( "," ) ,
427+ :location => vfc . location
428+ )
429+ end
430+ end
409431 end
410432
411433 def parse_vios_guest_devices ( vios , hardware )
@@ -546,6 +568,39 @@ def build_ethernet_dev(lpar, ent, hardware, controller_type)
546568 )
547569 end
548570
571+ def build_io_adapter ( adapter , hardware )
572+ # Parse physical adapter ports, if any.
573+ child_devices =
574+ case adapter
575+ when IbmPowerHmc ::PhysicalFibreChannelAdapter
576+ adapter . ports . map do |fcs |
577+ persister . guest_devices . build (
578+ :hardware => hardware ,
579+ :uid_ems => fcs . location ,
580+ :location => fcs . location ,
581+ :device_name => fcs . name . nil? ? fcs . location : fcs . name ,
582+ :device_type => "physical_port" ,
583+ :controller_type => "Fibre channel port" ,
584+ :address => fcs . wwpn ,
585+ :model => adapter . description ,
586+ :auto_detect => true
587+ )
588+ end
589+ end || [ ]
590+
591+ persister . guest_devices . build (
592+ :hardware => hardware ,
593+ :uid_ems => adapter . dr_name ,
594+ :location => adapter . dr_name ,
595+ :device_name => "Adapter" ,
596+ :device_type => "physical_port" ,
597+ :controller_type => "IO" ,
598+ :model => adapter . description ,
599+ :auto_detect => true ,
600+ :child_devices => child_devices
601+ )
602+ end
603+
549604 def self . parse_macaddr ( macaddr )
550605 macaddr . downcase . scan ( /\w {2}/ ) . join ( ':' ) unless macaddr . nil?
551606 end
0 commit comments