Skip to content

Commit 2bd9aa8

Browse files
authored
Merge pull request #126 from dberg1/vfc
collect fc ports and vfc client adapters
2 parents 43a54f5 + e285165 commit 2bd9aa8

File tree

6 files changed

+6030
-1684
lines changed

6 files changed

+6030
-1684
lines changed

app/models/manageiq/providers/ibm_power_hmc/inventory/collector/infra_manager.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ def vnics
219219
end.compact.to_h
220220
end
221221

222+
def vfc_client_adapters
223+
@vfc_client_adapters ||=
224+
lpars.map do |lpar|
225+
[lpar.uuid, connection.vfc_client_adapter(lpar.uuid)] unless lpar.vfc_client_uuids.empty?
226+
rescue IbmPowerHmc::Connection::HttpNotFound
227+
nil
228+
rescue => e
229+
$ibm_power_hmc_log.error("vfc client adapters query failed for #{lpar.uuid}: #{e}")
230+
raise
231+
end.compact.to_h
232+
end
233+
222234
def vscsi_client_adapters
223235
@vscsi_client_adapters ||=
224236
lpars.map do |lpar|

app/models/manageiq/providers/ibm_power_hmc/inventory/parser/infra_manager.rb

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

manageiq-providers-ibm_power_hmc.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2020
spec.require_paths = ["lib"]
2121

22-
spec.add_dependency "ibm_power_hmc", "~> 0.22.0"
22+
spec.add_dependency "ibm_power_hmc", "~> 0.24.0"
2323

2424
spec.add_development_dependency "manageiq-style"
2525
spec.add_development_dependency "simplecov", ">= 0.21.2"

0 commit comments

Comments
 (0)