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

Fix Host getting disconnected from Cluster when migrating a VM in RHEV #13815

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 @@ -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
Original file line number Diff line number Diff line change
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