davidjumani commented on a change in pull request #5215:
URL: https://github.com/apache/cloudstack/pull/5215#discussion_r685693760
##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -862,25 +861,48 @@ public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws
ResourceUnavailableExce
throw new InvalidParameterValueException("Vm " + userVm + " should
be stopped to do SSH Key reset");
}
- SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(),
owner.getDomainId(), cmd.getName());
- if (s == null) {
- throw new InvalidParameterValueException("A key pair with name '"
+ cmd.getName() + "' does not exist for account " + owner.getAccountName()
- + " in specified domain id");
+ String keypairnames = "";
+
+ List<SSHKeyPairVO> s_list = null;
+ if (cmd.getNames() != null) {
+ s_list = _sshKeyPairDao.findByNames(owner.getAccountId(),
owner.getDomainId(), cmd.getNames());
+ for (String keypairname : cmd.getNames()) {
+ if (keypairnames != "") {
+ keypairnames = keypairnames + ", ";
+ }
+ keypairnames = keypairnames + keypairname;
+ }
+ }
+ if (s_list == null) {
+ throw new InvalidParameterValueException("Any key pair with the
given names does not exist for account " + owner.getAccountName()
+ + " in specified domain id");
}
_accountMgr.checkAccess(caller, null, true, userVm);
- String sshPublicKey = s.getPublicKey();
+ String sshPublicKey = "";
- boolean result = resetVMSSHKeyInternal(vmId, sshPublicKey);
+ if (s_list != null) {
+ for (SSHKeyPairVO s_each : s_list) {
+ String publicKey = s_each.getPublicKey();
+ sshPublicKey = sshPublicKey + publicKey;
+ sshPublicKey = sshPublicKey + "\n";
+ s_logger.info("the public key for keypair name " +
s_each.getName() + " is " + publicKey);
+ }
+ }
+ boolean result = resetVMSSHKeyInternal(vmId, sshPublicKey,
keypairnames);
+
+ UserVmVO vm = _vmDao.findById(vmId);
+ _vmDao.loadDetails(vm);
+ _vmDao.saveDetails(vm);
Review comment:
Why is it being loaded and then immediately saved ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]