davidjumani commented on a change in pull request #5215:
URL: https://github.com/apache/cloudstack/pull/5215#discussion_r685694091



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -3785,17 +3807,32 @@ private UserVm createVirtualMachine(DataCenter zone, 
ServiceOffering serviceOffe
 
         // check if the user data is correct
         userData = validateUserData(userData, httpmethod);
-
         // Find an SSH public key corresponding to the key pair name, if one is
         // given
-        String sshPublicKey = null;
-        if (sshKeyPair != null && !sshKeyPair.equals("")) {
-            SSHKeyPair pair = _sshKeyPairDao.findByName(owner.getAccountId(), 
owner.getDomainId(), sshKeyPair);
-            if (pair == null) {
-                throw new InvalidParameterValueException("A key pair with name 
'" + sshKeyPair + "' was not found.");
-            }
+        String sshPublicKey = "";
+        String keypairnames = "";
 
-            sshPublicKey = pair.getPublicKey();
+        if (sshKeyPairs != null) {
+            for (String sshkeypair : sshKeyPairs) {
+                if (keypairnames != "") {
+                    keypairnames = keypairnames + ", ";
+                }
+                keypairnames = keypairnames + sshkeypair;
+            }
+            List<SSHKeyPairVO> pairs = 
_sshKeyPairDao.findByNames(owner.getAccountId(), owner.getDomainId(), 
sshKeyPairs);
+            for (SSHKeyPairVO pair : pairs) {
+                if (pair == null) {
+                    throw new InvalidParameterValueException("A key pair with 
name '" + pair.getName() + "' was not found.");
+                }
+                else {
+                    s_logger.info("publickey is " + pair.getPublicKey());
+                    sshPublicKey = sshPublicKey + pair.getPublicKey();
+                    sshPublicKey = sshPublicKey + "\n";
+                }
+            }
+        }

Review comment:
       Can this duplicate code be extracted out ?




-- 
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]


Reply via email to