-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CLOUDSTACK-9727 Password reset discrepancy in RVR when one of the Rou… #1965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -775,28 +775,33 @@ public boolean savePassword(final Network network, final NicProfile nic, final V | |
| } | ||
|
|
||
| final VirtualMachineProfile uservm = vm; | ||
|
|
||
| final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId()); | ||
| final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO); | ||
|
|
||
| // If any router is running then send save password command otherwise | ||
| // save the password in DB | ||
| if (!network.isRedundant()) { | ||
| return networkTopology.savePasswordToRouter(network, nic, uservm, routers.get(0)); | ||
| } | ||
|
|
||
| for (final VirtualRouter router : routers) { | ||
| if (router.getState() == State.Running) { | ||
| return networkTopology.savePasswordToRouter(network, nic, uservm, router); | ||
| } | ||
| if (router.getState() == State.Running && router.getRedundantState() == VirtualRouter.RedundantState.MASTER) { | ||
| return networkTopology.savePasswordToRouter(network, nic, uservm, router); | ||
| } | ||
| } | ||
| return savePassword(uservm); | ||
| } | ||
|
|
||
| private boolean savePassword(VirtualMachineProfile uservm) { | ||
| //save password | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. save password should be moved to a seperate method, as password should be saved to user_vm_details table if it is not applied to VR, at around line 773.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ustcweizhou |
||
| final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword); | ||
| final String password_encrypted = DBEncryptionUtil.encrypt(password); | ||
| final UserVmVO userVmVO = _userVmDao.findById(vm.getId()); | ||
| final UserVmVO userVmVO = _userVmDao.findById(uservm.getId()); | ||
|
|
||
| _userVmDao.loadDetails(userVmVO); | ||
| userVmVO.setDetail("password", password_encrypted); | ||
| _userVmDao.saveDetails(userVmVO); | ||
|
|
||
| userVmVO.setUpdateParameters(true); | ||
| _userVmDao.update(userVmVO.getId(), userVmVO); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 781 to line 794 can be more simple like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ustcweizhou
modified this code.