inter-cluster migration support

This commit is contained in:
Pearl Dsilva 2020-07-28 13:25:35 +05:30 committed by Harikrishna Patnala
parent 5aac6c3f0f
commit 4178a7cd90
4 changed files with 112 additions and 7 deletions

103
check_diff Normal file
View File

@ -0,0 +1,103 @@
diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index 47d3013f22..2dbf257fb2 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -5551,11 +5551,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new InvalidParameterValueException("Unable to find the VM by id=" + vmId);
}
- if (vm.getState() != State.Stopped) {
- InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Stopped, unable to migrate the vm having the specified id");
- ex.addProxyObject(vm.getUuid(), "vmId");
- throw ex;
- }
+// if (vm.getState() != State.Stopped) {
+// InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Stopped, unable to migrate the vm having the specified id");
+// ex.addProxyObject(vm.getUuid(), "vmId");
+// throw ex;
+// }
if (vm.getType() != VirtualMachine.Type.User) {
// OffLineVmwareMigration: *WHY* ?
@@ -5634,14 +5634,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new InvalidParameterValueException("Unable to find the VM by id=" + vmId);
}
// business logic
- if (vm.getState() != State.Running) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
- }
- InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, unable to migrate the vm with specified id");
- ex.addProxyObject(vm.getUuid(), "vmId");
- throw ex;
- }
+// if (vm.getState() != State.Running) {
+// if (s_logger.isDebugEnabled()) {
+// s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
+// }
+// InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, unable to migrate the vm with specified id");
+// ex.addProxyObject(vm.getUuid(), "vmId");
+// throw ex;
+// }
checkIfHostOfVMIsInPrepareForMaintenanceState(vm.getHostId(), vmId, "Migrate");
@@ -5987,15 +5987,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
// OfflineVmwareMigration: this would be it ;) if multiple paths exist: unify
- if (vm.getState() != State.Running) {
- // OfflineVmwareMigration: and not vmware
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
- }
- CloudRuntimeException ex = new CloudRuntimeException("VM is not Running, unable to migrate the vm with" + " specified id");
- ex.addProxyObject(vm.getUuid(), "vmId");
- throw ex;
- }
+// if (vm.getState() != State.Running) {
+// // OfflineVmwareMigration: and not vmware
+// if (s_logger.isDebugEnabled()) {
+// s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
+// }
+// CloudRuntimeException ex = new CloudRuntimeException("VM is not Running, unable to migrate the vm with" + " specified id");
+// ex.addProxyObject(vm.getUuid(), "vmId");
+// throw ex;
+// }
if(serviceOfferingDetailsDao.findDetail(vm.getServiceOfferingId(), GPU.Keys.pciDevice.toString()) != null) {
throw new InvalidParameterValueException("Live Migration of GPU enabled VM is not supported");
diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 62ecc9a5d5..36e102cb20 100644
--- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -34,8 +34,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import com.vmware.vim25.VStorageObject;
-import com.vmware.vim25.VStorageObjectConfigInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
@@ -2430,13 +2428,13 @@ public class VirtualMachineMO extends BaseMO {
String deviceNumbering = getDeviceBusName(devices, device);
s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
- if (((VirtualDisk) device).getVDiskId() == null) {
- s_logger.debug("vDiskid does not exist for volume " + vmdkDatastorePath + " registering the disk now");
- VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getOwnerDatacenter().first().getContext());
- VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
- VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
- ((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
- }
+// if (((VirtualDisk) device).getVDiskId() == null) {
+// s_logger.debug("vDiskid does not exist for volume " + vmdkDatastorePath + " registering the disk now");
+// VirtualStorageObjectManagerMO vStorageObjectManagerMO = new VirtualStorageObjectManagerMO(getOwnerDatacenter().first().getContext());
+// VStorageObject vStorageObject = vStorageObjectManagerMO.registerVirtualDisk(dsBackingFile, null, getOwnerDatacenter().first().getName());
+// VStorageObjectConfigInfo diskConfigInfo = vStorageObject.getConfig();
+// ((VirtualDisk) device).setVDiskId(diskConfigInfo.getId());
+// }
return new Pair<>((VirtualDisk)device, deviceNumbering);
}

View File

@ -2468,7 +2468,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
throw new CloudRuntimeException("Unable to find the host to migrate from: " + srcHostId);
}
if (fromHost.getClusterId().longValue() != dest.getCluster().getId()) {
if (fromHost.getClusterId().longValue() != dest.getCluster().getId() && vm.getHypervisorType() != HypervisorType.VMware) {
final List<VolumeVO> volumes = _volsDao.findCreatedByInstance(vm.getId());
for (final VolumeVO volume : volumes) {
if (!_storagePoolDao.findById(volume.getPoolId()).getScope().equals(ScopeType.ZONE)) {

View File

@ -4403,7 +4403,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
s_logger.debug("Preparing spec for volume : " + volume.getName());
morDsAtTarget = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(tgtHyperHost, filerTo.getUuid());
morDsAtSource = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost, filerTo.getUuid());
morDsAtSource = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost, volume.getPoolUuid());
if (morDsAtTarget == null) {
String msg = "Unable to find the target datastore: " + filerTo.getUuid() + " on target host: " + tgtHyperHost.getHyperHostName()
+ " to execute MigrateWithStorageCommand";
@ -4431,7 +4432,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
s_logger.debug("Mounted datastore " + tgtDsHost + ":/" + tgtDsPath + " on " + _hostName);
}
}
// If datastore is VMFS and target datastore is not mounted or accessible to source host then fail migration.
if (filerTo.getType().equals(StoragePoolType.VMFS) || filerTo.getType().equals(StoragePoolType.PreSetup)) {
if (morDsAtSource == null) {
@ -4452,6 +4452,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (volume.getType() == Volume.Type.ROOT) {
relocateSpec.setDatastore(morTgtDatastore);
}
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
diskLocator.setDatastore(morDsAtSource);
Pair<VirtualDisk, String> diskInfo = getVirtualDiskInfo(vmMo, appendFileType(volume.getPath(), VMDK_EXTENSION));
@ -4476,8 +4477,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
diskLocators.add(diskLocator);
}
}
relocateSpec.getDisk().addAll(diskLocators);
if (srcHyperHost.getHyperHostCluster().equals(tgtHyperHost.getHyperHostCluster())) {
relocateSpec.getDisk().addAll(diskLocators);
}
// Prepare network at target before migration
NicTO[] nics = vmTo.getNics();

View File

@ -34,8 +34,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import com.vmware.vim25.VStorageObject;
import com.vmware.vim25.VStorageObjectConfigInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
@ -63,6 +61,8 @@ import com.vmware.vim25.ParaVirtualSCSIController;
import com.vmware.vim25.PropertyFilterSpec;
import com.vmware.vim25.PropertySpec;
import com.vmware.vim25.TraversalSpec;
import com.vmware.vim25.VStorageObject;
import com.vmware.vim25.VStorageObjectConfigInfo;
import com.vmware.vim25.VirtualBusLogicController;
import com.vmware.vim25.VirtualCdrom;
import com.vmware.vim25.VirtualCdromIsoBackingInfo;