mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 10:02:27 +01:00
CLOUDSTACK-6146. [VMware] [ESXi 5.5] Live storage migration of an already migrated volume fails
In vCenter 5.5, once a volume is migrated the VMDKs are renamed to match the name of the VM. If a volume has been renamed upon migration update its volumePath to that of the new disk filename. Conflicts: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
This commit is contained in:
parent
b484b48201
commit
0926bf57f4
@ -3163,10 +3163,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(new DatastoreMO(srcHyperHost.getContext(), morDs), vmName, volumePath + ".vmdk");
|
DatastoreMO targetDsMo = new DatastoreMO(srcHyperHost.getContext(), morDs);
|
||||||
|
String fullVolumePath = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(targetDsMo, vmName, volumePath + ".vmdk");
|
||||||
|
int diskId = getVirtualDiskInfo(vmMo, volumePath + ".vmdk");
|
||||||
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
|
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
|
||||||
diskLocator.setDatastore(morDs);
|
diskLocator.setDatastore(morDs);
|
||||||
diskLocator.setDiskId(getVirtualDiskInfo(vmMo, volumePath + ".vmdk"));
|
diskLocator.setDiskId(diskId);
|
||||||
|
|
||||||
diskLocators.add(diskLocator);
|
diskLocators.add(diskLocator);
|
||||||
relocateSpec.getDisk().add(diskLocator);
|
relocateSpec.getDisk().add(diskLocator);
|
||||||
@ -3178,6 +3180,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
s_logger.debug("Successfully migrated volume " + volumePath + " to target datastore " + tgtDsName);
|
s_logger.debug("Successfully migrated volume " + volumePath + " to target datastore " + tgtDsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update and return volume path because that could have changed after migration
|
||||||
|
if (!targetDsMo.fileExists(fullVolumePath)) {
|
||||||
|
VirtualDisk[] disks = vmMo.getAllDiskDevice();
|
||||||
|
for (VirtualDisk disk : disks)
|
||||||
|
if (disk.getKey() == diskId) {
|
||||||
|
volumePath = vmMo.getVmdkFileBaseName(disk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new MigrateVolumeAnswer(cmd, true, null, volumePath);
|
return new MigrateVolumeAnswer(cmd, true, null, volumePath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
|
String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
|
||||||
|
|||||||
@ -1800,17 +1800,23 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
VirtualDevice[] devices = getAllDiskDevice();
|
VirtualDevice[] devices = getAllDiskDevice();
|
||||||
for(VirtualDevice device : devices) {
|
for(VirtualDevice device : devices) {
|
||||||
if(device instanceof VirtualDisk) {
|
if(device instanceof VirtualDisk) {
|
||||||
VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
|
vmdkFileBaseNames.add(getVmdkFileBaseName((VirtualDisk)device));
|
||||||
if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
|
|
||||||
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
|
|
||||||
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
|
||||||
vmdkFileBaseNames.add(dsBackingFile.getFileBaseName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vmdkFileBaseNames;
|
return vmdkFileBaseNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVmdkFileBaseName(VirtualDisk disk) throws Exception {
|
||||||
|
String vmdkFileBaseName = null;
|
||||||
|
VirtualDeviceBackingInfo backingInfo = disk.getBacking();
|
||||||
|
if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
|
||||||
|
VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
|
||||||
|
DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
|
||||||
|
vmdkFileBaseName = dsBackingFile.getFileBaseName();
|
||||||
|
}
|
||||||
|
return vmdkFileBaseName;
|
||||||
|
}
|
||||||
|
|
||||||
// this method relies on un-offical VMware API
|
// this method relies on un-offical VMware API
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void moveAllVmDiskFiles(DatastoreMO destDsMo, String destDsDir, boolean followDiskChain) throws Exception {
|
public void moveAllVmDiskFiles(DatastoreMO destDsMo, String destDsDir, boolean followDiskChain) throws Exception {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user