Skip to content

Commit 682d7bd

Browse files
bvbharatbvbharatk
authored andcommitted
CLOUDSTACK-9727 Password reset discrepancy in RVR when one of the Router is not in Running state.
1 parent cd68e99 commit 682d7bd

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -779,24 +779,37 @@ public boolean savePassword(final Network network, final NicProfile nic, final V
779779
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
780780
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
781781

782-
// If any router is running then send save password command otherwise
783-
// save the password in DB
782+
// If any router is not running then save the password in DB
783+
List<VirtualRouter> routerList = new ArrayList<VirtualRouter>();
784+
//applied true implies we have applied the password successfully on at
785+
//least one router. save true implies we have to save the password to send
786+
//it to the remaining routers.
787+
Boolean applied = true, save = false;
784788
for (final VirtualRouter router : routers) {
785789
if (router.getState() == State.Running) {
786-
return networkTopology.savePasswordToRouter(network, nic, uservm, router);
787-
}
790+
routerList.add(router);
791+
} else save = true;
788792
}
789-
final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
790-
final String password_encrypted = DBEncryptionUtil.encrypt(password);
791-
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
792-
793-
_userVmDao.loadDetails(userVmVO);
794-
userVmVO.setDetail("password", password_encrypted);
795-
_userVmDao.saveDetails(userVmVO);
793+
for (VirtualRouter router : routerList) {
794+
applied = networkTopology.savePasswordToRouter(network, nic, uservm, router);
795+
if (!applied)
796+
break;
797+
}
798+
if (save && applied) {
799+
final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
800+
final String password_encrypted = DBEncryptionUtil.encrypt(password);
801+
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
796802

797-
userVmVO.setUpdateParameters(true);
798-
_userVmDao.update(userVmVO.getId(), userVmVO);
803+
_userVmDao.loadDetails(userVmVO);
804+
userVmVO.setDetail("password", password_encrypted);
805+
_userVmDao.saveDetails(userVmVO);
799806

807+
userVmVO.setUpdateParameters(true);
808+
_userVmDao.update(userVmVO.getId(), userVmVO);
809+
}
810+
if (!save && !applied) {
811+
return false;
812+
}
800813
return true;
801814
}
802815

0 commit comments

Comments
 (0)