Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -702,18 +702,32 @@ public boolean savePassword(final Network network, final NicProfile nic, final V

// If any router is running then send save password command otherwise
// save the password in DB
boolean savePasswordResult = true;
boolean isVrRunning = false;
Comment thread
GabrielBrascher marked this conversation as resolved.
for (final VirtualRouter router : routers) {
if (router.getState() == State.Running) {
final boolean result = networkTopology.savePasswordToRouter(network, nic, uservm, router);
if (result) {
// Explicit password reset, while VM hasn't generated a password yet.
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
userVmVO.setUpdateParameters(false);
_userVmDao.update(userVmVO.getId(), userVmVO);
if (!result) {
s_logger.error("Unable to save password for VM " + vm.getInstanceName() +
" on router " + router.getInstanceName());
return false;
}
return result;
isVrRunning = true;
savePasswordResult = savePasswordResult && result;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ravening it seems savePasswordResult is not needed any more, because it is always true.

}
}

// return the result only if one of the vr is running
if (isVrRunning) {
if (savePasswordResult) {
// Explicit password reset, while VM hasn't generated a password yet.
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
userVmVO.setUpdateParameters(false);
_userVmDao.update(userVmVO.getId(), userVmVO);
}
return savePasswordResult;
}

final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
final String password_encrypted = DBEncryptionUtil.encrypt(password);
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
Expand Down