diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index aa1b8c0f4b0..a37992609d5 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -1796,7 +1796,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa s_logger.error(msg); throw new Exception(msg); } - + if (!vmMo.relocate(morTargetPhysicalHost)) { String msg = "VM " + vmName + " is on other host and we failed to relocate it here"; s_logger.error(msg); @@ -2149,6 +2149,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa final String vmName = vm.getName(); try { VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); + VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); // find VM through datacenter (VM is not at the target host yet) VirtualMachineMO vmMo = hyperHost.findVmOnPeerHyperHost(vmName); @@ -2162,7 +2163,20 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa for (NicTO nic : nics) { // prepare network on the host prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic); - } + } + + String secStoreUrl = mgr.getSecondaryStorageStoreUrl(Long.parseLong(_dcId)); + if(secStoreUrl == null) { + String msg = "secondary storage for dc " + _dcId + " is not ready yet?"; + throw new Exception(msg); + } + mgr.prepareSecondaryStorageStore(secStoreUrl); + + ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl); + if (morSecDs == null) { + String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl; + throw new Exception(msg); + } synchronized (_vms) { _vms.put(vm.getName(), State.Migrating); @@ -2211,7 +2225,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa if (morTargetPhysicalHost == null) { throw new Exception("Unable to find a target capable physical host"); } - + if (!vmMo.migrate(destHyperHost.getHyperHostOwnerResourcePool(), morTargetPhysicalHost)) { throw new Exception("Migration failed"); } @@ -3582,7 +3596,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } return VirtualMachineGuestOsIdentifier.otherGuest; } - + private HashMap getVmStates() throws Exception { VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] { "name", "runtime.powerState", "config.template" });