CLOUDSTACK-5122. System VMs are getting recreated with old template after upgrading to 4.2.

In VMware during VM start the existing disk information is used to configure the VMs. So even if a new disk is created using the new template VM continues to use the old disk.
Once the old root disk is marked for destroy force expunge it and sync the new disk into the VM folder before VM start
This commit is contained in:
Likitha Shetty 2013-11-10 23:31:56 +05:30
parent d5632189dc
commit a35425eec6
2 changed files with 11 additions and 3 deletions

View File

@ -738,6 +738,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
} catch (NoTransitionException e) {
s_logger.debug("Unable to destroy existing volume: " + e.toString());
}
// In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk
if (vm.getHypervisorType() == HypervisorType.VMware) {
s_logger.info("Expunging volume " + existingVolume.getId() + " from primary data store");
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId()));
try {
future.get();
} catch (Exception e) {
s_logger.debug("Failed to expunge volume:" + existingVolume.getId(), e);
}
}
return newVolume;
}

View File

@ -383,9 +383,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
// restoreVM - move the new ROOT disk into corresponding VM folder
String vmInternalCSName = volume.getVmName();
if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmInternalCSName)) {
String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkName);
if (oldRootDisk != null)
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
}
VolumeObjectTO newVol = new VolumeObjectTO();