CLOUDSTACK-2792: Send "saved_password" to BACKUP router when reset password for user VM

Otherwise when MASTER failed, the user VM would get password reset again after
reboot.

But this fix still have issues if MASTER is failure before VM boot up, but in
that case, password of user VM won't change and user would request password
change again, then it would be fine.
This commit is contained in:
Sheng Yang 2013-05-31 16:29:03 -07:00
parent fbe6b273e3
commit 5a8a2a259e
1 changed files with 6 additions and 1 deletions

View File

@ -3353,7 +3353,12 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
// password should be set only on default network element
if (password != null && nic.isDefaultNic()) {
final String encodedPassword = PasswordGenerator.rot13(password);
String encodedPassword = PasswordGenerator.rot13(password);
// We would unset password for BACKUP router in the RvR, to prevent user from accidently reset the
// password again after BACKUP become MASTER
if (router.getIsRedundantRouter() && router.getRedundantState() != RedundantState.MASTER) {
encodedPassword = PasswordGenerator.rot13("saved_password");
}
SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getHostName());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(nic.getNetworkId(), router.getId()));