shwstppr commented on code in PR #10720:
URL: https://github.com/apache/cloudstack/pull/10720#discussion_r2048530676


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3805,11 +3805,18 @@ public UserVm createAdvancedVirtualMachine(DataCenter 
zone, ServiceOffering serv
     @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = 
"deploying Vm")
     public UserVm finalizeCreateVirtualMachine(long vmId) {
         s_logger.info("Loading UserVm " + vmId + " from DB");
-        UserVm userVm = getUserVm(vmId);
+        UserVmVO userVm = _vmDao.findById(vmId);
         if (userVm == null) {
             s_logger.info("Loaded UserVm " + vmId + " (" + userVm.getUuid() + 
") from DB");
         } else {
             s_logger.warn("UserVm " + vmId + " does not exist in DB");
+            VMTemplateVO template = 
_templateDao.findById(userVm.getTemplateId());
+            if (template != null && template.isEnablePassword()) {
+                String password = _mgr.generateRandomPassword();
+                _vmDao.loadDetails(userVm);
+                userVm.setPassword(password);
+                encryptAndStorePassword(userVm, password);
+            }

Review Comment:
   @DaanHoogland generate and store method are used differently in different 
place. A refactoring to consolidate can be done in a separate PR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to