diff --git a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb index b58be6862..2bebc9ee7 100644 --- a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb +++ b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb @@ -145,6 +145,7 @@ def self.host_inv_to_hashes(inv, ems_inv, cluster_uids, _storage_uids) :ems_cluster => cluster_uids[host_inv.attributes.fetch_path(:cluster, :id)], :hardware => hardware, :switches => switches, + :host_switches => switches, } new_result[:ipmi_address] = ipmi_address unless ipmi_address.blank? diff --git a/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb b/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb index c335cfbcb..faa794d3e 100644 --- a/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb +++ b/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb @@ -240,7 +240,8 @@ def host_guest_devices(persister_hardware, host, nics, networks) unless network.nil? switch_uid = network.try(:id) || network.name - attributes[:switch] = persister.switches.lazy_find(switch_uid) + persister_host = persister.hosts.lazy_find(ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(host.href)) + attributes[:switch] = persister.host_virtual_switches.lazy_find(:host => persister_host, :uid_ems => switch_uid) attributes[:network] = persister_nic end @@ -260,7 +261,8 @@ def switches(persister_host, dc, nics, networks) uid = network.try(:id) || network.name name = network.name - persister_switch = persister.switches.find_or_build(uid).assign_attributes( + persister_switch = persister.host_virtual_switches.find_or_build_by(:host => persister_host, :uid_ems => uid).assign_attributes( + :host => persister_host, :uid_ems => uid, :name => name, :lans => [lans(network)] diff --git a/app/models/manageiq/providers/redhat/inventory/persister/infra_manager.rb b/app/models/manageiq/providers/redhat/inventory/persister/infra_manager.rb index 01951239d..c8b1a19ea 100644 --- a/app/models/manageiq/providers/redhat/inventory/persister/infra_manager.rb +++ b/app/models/manageiq/providers/redhat/inventory/persister/infra_manager.rb @@ -5,7 +5,7 @@ def initialize_inventory_collections %i(ems_clusters hosts resource_pools vms miq_templates storages vm_and_template_ems_custom_fields disks guest_devices hardwares host_hardwares host_networks host_operating_systems host_storages - host_switches lans networks operating_systems snapshots switches) + host_switches lans networks operating_systems snapshots host_virtual_switches) ) add_inventory_collection( diff --git a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb index 77308700e..7474b723e 100644 --- a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb +++ b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb @@ -112,8 +112,7 @@ def assert_table_counts(_lan_number) expect(Network.count).to eq(6) expect(OperatingSystem.count).to eq(20) expect(Snapshot.count).to eq(17) - # the old code expects 3 and new 2 - expect(Switch.count).to eq(2) + expect(Switch.count).to eq(3) expect(SystemService.count).to eq(0) expect(Relationship.count).to eq(45)