Skip to content

Commit

Permalink
Merge pull request #361 from agrare/fix_duplicate_datastore_location_…
Browse files Browse the repository at this point in the history
…handling

Handle duplicate storages in the refresh parser

(cherry picked from commit c716f77)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1765583
  • Loading branch information
Ladas authored and simaishi committed Oct 25, 2019
1 parent 1ddd98a commit c7aebad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
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

0 comments on commit c7aebad

Please sign in to comment.