Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle duplicate storages in the refresh parser #361

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def self.ems_inv_to_hashes(inv)
def self.storage_inv_to_hashes(inv)
result = []
result_uids = {}
result_locs = {}
return result, result_uids if inv.nil?

inv.each do |mor, storage_inv|
Expand All @@ -54,6 +55,10 @@ def self.storage_inv_to_hashes(inv)
capability = storage_inv["capability"]

loc = uid = normalize_storage_uid(storage_inv)
unless result_locs[loc].nil?
result_uids[mor] = result_locs[loc]
next
end

new_result = {
:ems_ref => mor,
Expand All @@ -77,6 +82,7 @@ def self.storage_inv_to_hashes(inv)

result << new_result
result_uids[mor] = new_result
result_locs[loc] = new_result
end
return result, result_uids
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@
end

it "will perform a full refresh" do
EmsRefresh.refresh(@ems)
@ems.reload

assert_table_counts
assert_ems
assert_specific_datacenter
assert_specific_folder
assert_specific_cluster
assert_specific_storage
assert_specific_storage_cluster
assert_specific_storage_profile
assert_specific_dvportgroup
assert_specific_host
assert_specific_vm
assert_specific_vm_missing_uuid
assert_cpu_layout
assert_relationship_tree
2.times do
EmsRefresh.refresh(@ems)
@ems.reload

assert_table_counts
assert_ems
assert_specific_datacenter
assert_specific_folder
assert_specific_cluster
assert_specific_storage
assert_specific_storage_cluster
assert_specific_storage_profile
assert_specific_dvportgroup
assert_specific_host
assert_specific_vm
assert_specific_vm_missing_uuid
assert_cpu_layout
assert_relationship_tree
end
end

it 'handles switch deletion' do
Expand Down Expand Up @@ -252,7 +254,7 @@ def assert_table_counts
expect(VmOrTemplate.count).to eq(101)
expect(Vm.count).to eq(92)
expect(MiqTemplate.count).to eq(9)
expect(Storage.count).to eq(50)
expect(Storage.count).to eq(33)
expect(StorageProfile.count).to eq(6)

expect(CustomAttribute.count).to eq(3)
Expand Down Expand Up @@ -282,7 +284,7 @@ def assert_ems
expect(@ems.ems_folders.size).to eq(32)
expect(@ems.ems_clusters.size).to eq(1)
expect(@ems.resource_pools.size).to eq(17)
expect(@ems.storages.size).to eq(47)
expect(@ems.storages.size).to eq(30)
expect(@ems.hosts.size).to eq(4)
expect(@ems.vms_and_templates.size).to eq(101)
expect(@ems.vms.size).to eq(92)
Expand Down