Skip to content

Commit

Permalink
Add :ems_cluster to the partial host hash
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Feb 8, 2017
1 parent b918c71 commit b448a14
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Expand Up @@ -404,7 +404,8 @@ def self.vm_inv_to_hashes(inv, _storage_inv, storage_uids, cluster_uids, host_ui

# If the vm has a host but the refresh does not include it in the "hosts" hash
if host.blank? && vm_inv[:host].present?
host = partial_host_hash(vm_inv[:host])
host_inv = vm_inv[:host].merge(:cluster => ems_cluster)
host = partial_host_hash(host_inv)
added_hosts << host if host
end

Expand Down Expand Up @@ -445,7 +446,11 @@ def self.vm_inv_to_hashes(inv, _storage_inv, storage_uids, cluster_uids, host_ui

def self.partial_host_hash(partial_host_inv)
ems_ref = ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(partial_host_inv[:href])
{ :ems_ref => ems_ref, :uid_ems => partial_host_inv[:id] }
{
:ems_ref => ems_ref,
:uid_ems => partial_host_inv[:id],
:ems_cluster => partial_host_inv[:cluster]
}
end

def self.create_vm_hash(template, ems_ref, vm_id, name)
Expand Down
Expand Up @@ -85,13 +85,41 @@
@ems.reload
vm = @ems.vms.where(:name => "migrate_test_1").first
expect(vm.host.name).to eq("pluto-vdsg.eng.lab.tlv.redhat.com")
expect(vm.host.ems_ref).to eq("/api/hosts/0b4c3cf3-3b51-479a-bd36-ab968151a9a9")

assert_host(vm.host)

VCR.use_cassette("#{described_class.name.underscore}_after_migration", :allow_unused_http_interactions => true) do
EmsRefresh.refresh(vm)
end

vm.reload

# Check that the VM is on a new host
expect(vm.host.name).to eq("lilach-vdsa.tlv.redhat.com")
expect(vm.host.ems_ref).to eq("/api/hosts/bfb0c0b4-8616-4bbf-9210-9de48892adc6")

# And everything else about the hosts are the same
assert_host(vm.host)
end

def assert_host(host)
expect(host.ems_cluster).not_to be_nil
expect(host.ems_cluster.name).to eq("Default")

expect(host.storages.count).to eq(1)

storage = host.storages.find_by(:name => "data1_new")
expect(storage.ems_ref).to eq("/api/storagedomains/2ef34a5b-2046-4707-9180-7723aad1b8ce")

expect(host.lans.count).to eq(2)
lan = host.lans.find_by(:name => "rhevm")
expect(lan.name).to eq("rhevm")

expect(host.switches.count).to eq(2)
switch = host.switches.find_by(:name => "rhevm")
expect(switch.name).to eq("rhevm")
expect(switch.lans).to include(lan)
end
end

Expand Down

0 comments on commit b448a14

Please sign in to comment.