mirror of https://github.com/apache/cloudstack.git
server: send VM password to all Running VRs in network/vpc (#3903)
Currently, the cloudstack sends VM password only to the first router in the network even if its the backup and return the result. In some cases the first router will be back up and the second will be master. Since password server is not running in backup, when the user resets the password, it is sent to the first router which can be backup. In that case, the new password is not stored in the password server and users cant log in with a new password. This change ensures that we send the password to both the routers instead of the first router so that a new password is stored in the master router.
This commit is contained in:
parent
4d8a2da133
commit
abb39a25af
|
|
@ -702,18 +702,32 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource, DnsServ
|
|||
|
||||
// If any router is running then send save password command otherwise
|
||||
// save the password in DB
|
||||
boolean savePasswordResult = true;
|
||||
boolean isVrRunning = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue