From 41f2c75aee69dc15de2acd0199ac7318ab3f291e Mon Sep 17 00:00:00 2001 From: Sateesh Chodapuneedi Date: Mon, 19 Aug 2013 05:52:13 +0530 Subject: [PATCH] CLOUDSTACK-4385 : [ZWPS]Across the cluster live migration of VM on zone wide primary storage pool fails If all the VM's volumes are on zone wide primary storage pool then live migration of the VM would not involve storage migration. Hence MigrateVM API would be called against MigrateVMWithVolume. So far PrepareForMigrationCommand handled scenarios of VM moving across hosts within a cluster, but with zone wide primary storage in picture this command need to handle scenarios of VM moving across clusters. Try to find the VM in datacenter if not found within cluster. Signed-off-by: Sateesh Chodapuneedi --- .../hypervisor/vmware/resource/VmwareResource.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 14381119e92..5ab22164717 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -3723,9 +3723,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // find VM through datacenter (VM is not at the target host yet) VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName); if (vmMo == null) { - String msg = "VM " + vmName + " does not exist in VMware datacenter"; - s_logger.error(msg); - throw new Exception(msg); + s_logger.info("VM " + vmName + " was not found in the cluster of host " + hyperHost.getHyperHostName() + ". Looking for the VM in datacenter."); + ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter(); + DatacenterMO dcMo = new DatacenterMO(hyperHost.getContext(), dcMor); + vmMo = dcMo.findVm(vmName); + if (vmMo == null) { + String msg = "VM " + vmName + " does not exist in VMware datacenter"; + s_logger.error(msg); + throw new Exception(msg); + } } NicTO[] nics = vm.getNics();