mirror of https://github.com/apache/cloudstack.git
bug 12039,12041: when taking snapshot for detached volume, keep the worker VM around until backup copy to SSVM is done
Reviewed-by: Frank
This commit is contained in:
parent
9676947175
commit
08339d663f
|
|
@ -158,7 +158,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String snapshotBackupUuid = null;
|
||||
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
VirtualMachineMO vmMo;
|
||||
VirtualMachineMO vmMo = null;
|
||||
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
|
|
@ -201,11 +201,22 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
throw new Exception("Failed to take snapshot " + cmd.getSnapshotName() + " on vm: " + cmd.getVmName());
|
||||
}
|
||||
}
|
||||
|
||||
snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
||||
UUID.randomUUID().toString().replace("-", ""));
|
||||
|
||||
success = (snapshotBackupUuid != null);
|
||||
if (success) {
|
||||
details = "Successfully backedUp the snapshotUuid: " + snapshotUuid + " to secondary storage.";
|
||||
}
|
||||
|
||||
} finally {
|
||||
if(vmMo != null)
|
||||
vmMo.removeAllSnapshots();
|
||||
|
||||
try {
|
||||
if (workerVm != null) {
|
||||
// detach volume and destroy worker vm
|
||||
workerVm.moveAllVmDiskFiles(dsMo, "", false);
|
||||
workerVm.detachAllDisks();
|
||||
workerVm.destroy();
|
||||
}
|
||||
|
|
@ -213,16 +224,6 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
s_logger.warn("Failed to destroy worker VM: " + workerVMName);
|
||||
}
|
||||
}
|
||||
|
||||
snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
||||
hostService.getWorkerName(context, cmd));
|
||||
|
||||
success = (snapshotBackupUuid != null);
|
||||
|
||||
if (success) {
|
||||
details = "Successfully backedUp the snapshotUuid: " + snapshotUuid + " to secondary storage.";
|
||||
vmMo.removeAllSnapshots();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
|
|
@ -299,7 +300,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
try {
|
||||
Ternary<String, Long, Long> result = createTemplateFromSnapshot(accountId,
|
||||
newTemplateId, uniqeName,
|
||||
secondaryStorageUrl, volumeId,
|
||||
secondaryStorageUrl, volumeId,
|
||||
backedUpSnapshotUuid);
|
||||
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, null,
|
||||
|
|
|
|||
Loading…
Reference in New Issue