Skip to content

Commit

Permalink
Merge pull request #449 from agrare/collect_opaque_networks
Browse files Browse the repository at this point in the history
Collect OpaqueNetworks and OpaqueSwitches
  • Loading branch information
Ladas authored Sep 17, 2019
2 parents e524b83 + 21d7d0a commit 0b96575
Show file tree
Hide file tree
Showing 4 changed files with 1,029 additions and 773 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,22 @@ def self.host_inv_to_switch_hashes(inv)
pnics.each { |pnic| result_uids[:pnic_id][pnic] = new_result unless pnic.blank? }
end

inv["opaqueSwitch"].to_miq_a.each do |data|
uid = data["key"]

new_result = {
:uid_ems => uid,
:name => data["name"],
:type => "ManageIQ::Providers::Vmware::InfraManager::HostVirtualSwitch",
:lans => []
}

result << new_result
result_uids[uid] = new_result

data["pnic"].to_miq_a.compact.each { |pnic| result_uids[:pnic_id][pnic] = new_result }
end

return result, result_uids
end

Expand Down Expand Up @@ -543,6 +559,27 @@ def self.host_inv_to_lan_hashes(inv, switch_uids, dvpg_uids)
switch[:lans] << new_result
end

inv["opaqueNetwork"].to_miq_a.each do |data|
# There doesn't seem to be a good way of linking an opaqueNetwork to a specific opaqueSwitch
#
# For the purposes of provisioning we just need to know what hosts an opaqueNetwork is connected to so
# picking the first switch is sufficient.
opaque_switch_keys = inv["opaqueSwitch"].to_miq_a.pluck("key").sort
switch = switch_uids[opaque_switch_keys.first]
next if switch.nil?

uid = data["opaqueNetworkId"]

new_result = {
:uid_ems => uid,
:name => data["opaqueNetworkName"]
}

result << new_result
result_uids[uid] = new_result
switch[:lans] << new_result
end

return result, result_uids
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ module ManageIQ::Providers::Vmware::InfraManager::SelectorSpec
"config.network.dnsConfig.domainName",
"config.network.dnsConfig.hostName",
"config.network.ipRouteConfig.defaultGateway",
"config.network.opaqueNetwork[*].opaqueNetworkId",
"config.network.opaqueNetwork[*].opaqueNetworkName",
"config.network.opaqueNetwork[*].opaqueNetworkType",
"config.network.opaqueSwitch[*].key",
"config.network.opaqueSwitch[*].name",
"config.network.opaqueSwitch[*].pnic",
"config.network.opaqueSwitch[*].status",
"config.network.pnic[*].device",
"config.network.pnic[*].key",
"config.network.pnic[*].pci",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ def assert_table_counts
expect(Disk.count).to eq(421)
expect(GuestDevice.count).to eq(135)
expect(Hardware.count).to eq(105)
expect(Lan.count).to eq(16)
expect(Lan.count).to eq(18)
expect(MiqScsiLun.count).to eq(73)
expect(MiqScsiTarget.count).to eq(73)
expect(Network.count).to eq(75)
expect(OperatingSystem.count).to eq(105)
expect(Snapshot.count).to eq(29)
expect(Switch.count).to eq(9)
expect(Switch.count).to eq(11)
expect(SystemService.count).to eq(29)

expect(Relationship.count).to eq(247)
Expand Down Expand Up @@ -495,7 +495,7 @@ def assert_specific_host
:running => true
)

expect(@host.switches.size).to eq(3)
expect(@host.switches.size).to eq(4)

dvswitch = @host.switches.find_by(:name => "DC1_DVS")
expect(dvswitch).to have_attributes(
Expand Down Expand Up @@ -561,6 +561,20 @@ def assert_specific_host
:computed_mac_changes => true
)

opaque_switch = @host.switches.find_by(:uid_ems => "82 6f 15 38 57 ff 40 03-aa b1 0e 96 0e 11 ce a6")
expect(opaque_switch).to have_attributes(
:name => "NSX_Switch1",
:uid_ems => "82 6f 15 38 57 ff 40 03-aa b1 0e 96 0e 11 ce a6",
:shared => nil,
:switch_uuid => nil
)

opaque_network = opaque_switch.lans.find_by(:uid_ems => "2aa2e41b-8b23-4043-ae1d-1e191cab15f4")
expect(opaque_network).to have_attributes(
:name => "NSX_Network2",
:uid_ems => "2aa2e41b-8b23-4043-ae1d-1e191cab15f4"
)

expect(@host.hardware).to have_attributes(
:cpu_speed => 2127,
:cpu_type => "Intel(R) Xeon(R) CPU E5506 @ 2.13GHz",
Expand Down
Loading

0 comments on commit 0b96575

Please sign in to comment.