Skip to content

Commit 2c08c76

Browse files
committed
server: skip setting vm password when restored from backup
Fixes #11941 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent bfc4f60 commit 2c08c76

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5302,6 +5302,11 @@ private UserVm startVirtualMachine(long vmId, Long podId, Long clusterId, Long h
53025302
updateVmStateForFailedVmCreation(vm.getId(), hostId);
53035303
}
53045304

5305+
Object backupId = CallContext.current().getContextParameter(ApiConstants.BACKUP_ID);
5306+
if (backupId != null) {
5307+
logger.debug("VM is restored from backup, skipping password setting");
5308+
return vm;
5309+
}
53055310
// Check that the password was passed in and is valid
53065311
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
53075312
if (template.isEnablePassword()) {
@@ -9763,6 +9768,7 @@ public UserVm restoreVMFromBackup(CreateVMFromBackupCmd cmd) throws ResourceUnav
97639768
}
97649769

97659770
if (cmd.getStartVm()) {
9771+
CallContext.current().putContextParameter(ApiConstants.BACKUP_ID, cmd.getBackupId());
97669772
Long podId = null;
97679773
Long clusterId = null;
97689774
if (cmd instanceof CreateVMFromBackupCmdByAdmin) {

0 commit comments

Comments
 (0)