mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
Prepare secondary storage in migration target host before migration happens, unlike primary storage, secondary storage is prepared on-demand
This commit is contained in:
parent
e6b1929d1a
commit
dcee71e923
@ -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<String, State> getVmStates() throws Exception {
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] { "name", "runtime.powerState", "config.template" });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user