Skip to content

Commit

Permalink
Fix graph refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Feb 13, 2019
1 parent ea5648c commit 68b68f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def host_hardware(persister_host, host, networks, nics)
end

def host_guest_devices(persister_hardware, host, nics, networks)
persister_host = persister_hardware.host

nics.to_miq_a.each do |nic|
network = network_from_nic(nic, host, networks)
ip = nic.ip.presence || nil
Expand Down Expand Up @@ -239,7 +241,7 @@ 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)
attributes[:switch] = persister.host_virtual_switches.lazy_find(:host => persister_host, :uid_ems => switch_uid)
attributes[:network] = persister_nic
end

Expand All @@ -259,7 +261,10 @@ 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,
)
Expand Down Expand Up @@ -306,7 +311,9 @@ def lans(network, persister_switch)
return
end

persister.lans.find_or_build(uid).assign_attributes(
persister.lans.find_or_build_by(
:switch => persister_switch, :uid_ems => uid
).assign_attributes(
:name => name,
:uid_ems => uid,
:tag => tag_value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraColl
include ::ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraGroup::VmsCollections
include ::ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraGroup::DatacentersCollections
include ::ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraGroup::StoragedomainsCollections
include ::ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraGroup::NetworksCollections
include ::ManageIQ::Providers::Redhat::Inventory::Persister::Definitions::InfraGroup::VmsDependencyCollections

def initialize_infra_inventory_collections
Expand All @@ -16,9 +15,7 @@ def initialize_infra_inventory_collections
add_hosts_group
add_datacenters_group
add_storagedomains_group
add_networks_group
add_vms_dependency_collections_group
add_other_collections
end

# --- IC groups definitions ---
Expand Down Expand Up @@ -59,7 +56,9 @@ def add_hosts_group
host_networks
host_operating_systems
host_storages
host_switches).each do |name|
host_switches
host_virtual_switches
lans).each do |name|

add_collection(infra, name)
end
Expand All @@ -68,16 +67,4 @@ def add_hosts_group
def add_storagedomains_group
add_storages
end

def add_networks_group
add_switches
end

def add_other_collections
add_collection(infra, :lans) do |builder|
builder.add_properties(
:manager_ref => %i(uid_ems)
)
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 68b68f3

Please sign in to comment.