Skip to content

Commit 116e7e9

Browse files
Rakesh Venkateshravening
authored andcommitted
Send VM password to MASTER VR in case its the second vr in network
Currently the cloudstack sends VM password only to the first router in the network even if its the backup and return the result. Since password server is not running in backup, when user resets the password, it is sent to first router which can be backup in some case. In that case the new password is not stored and users cant login. This change ensures that we send passwrod to both the routers instead of the first router so that new password in stored in the master router.
1 parent ac7bcde commit 116e7e9

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

server/src/main/java/com/cloud/network/element/VirtualRouterElement.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,18 +702,27 @@ public boolean savePassword(final Network network, final NicProfile nic, final V
702702

703703
// If any router is running then send save password command otherwise
704704
// save the password in DB
705+
boolean savePasswordResult = true;
706+
boolean isVrRunning = false;
705707
for (final VirtualRouter router : routers) {
706708
if (router.getState() == State.Running) {
707709
final boolean result = networkTopology.savePasswordToRouter(network, nic, uservm, router);
708-
if (result) {
709-
// Explicit password reset, while VM hasn't generated a password yet.
710-
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
711-
userVmVO.setUpdateParameters(false);
712-
_userVmDao.update(userVmVO.getId(), userVmVO);
713-
}
714-
return result;
710+
isVrRunning = true;
711+
savePasswordResult = savePasswordResult & result;
715712
}
716713
}
714+
715+
// return the result only if one of the vr is running
716+
if (isVrRunning) {
717+
if (savePasswordResult) {
718+
// Explicit password reset, while VM hasn't generated a password yet.
719+
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
720+
userVmVO.setUpdateParameters(false);
721+
_userVmDao.update(userVmVO.getId(), userVmVO);
722+
}
723+
return savePasswordResult;
724+
}
725+
717726
final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
718727
final String password_encrypted = DBEncryptionUtil.encrypt(password);
719728
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());

0 commit comments

Comments
 (0)