Skip to content

Commit 9d02cd0

Browse files
committed
server: generate password for VM created in stopped state
Fixes #10294 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent f13cf59 commit 9d02cd0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3805,11 +3805,18 @@ public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serv
38053805
@ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm")
38063806
public UserVm finalizeCreateVirtualMachine(long vmId) {
38073807
s_logger.info("Loading UserVm " + vmId + " from DB");
3808-
UserVm userVm = getUserVm(vmId);
3808+
UserVmVO userVm = _vmDao.findById(vmId);
38093809
if (userVm == null) {
38103810
s_logger.info("Loaded UserVm " + vmId + " (" + userVm.getUuid() + ") from DB");
38113811
} else {
38123812
s_logger.warn("UserVm " + vmId + " does not exist in DB");
3813+
VMTemplateVO template = _templateDao.findById(userVm.getTemplateId());
3814+
if (template != null && template.isEnablePassword()) {
3815+
String password = _mgr.generateRandomPassword();
3816+
_vmDao.loadDetails(userVm);
3817+
userVm.setPassword(password);
3818+
encryptAndStorePassword(userVm, password);
3819+
}
38133820
}
38143821
return userVm;
38153822
}

0 commit comments

Comments
 (0)