You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2018/12/22 19:05:01 UTC

[cloudstack] branch 4.11 updated: api: allow keyword search in listSSHKeyPairs (#2920) (#3098)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.11 by this push:
     new a7ccbdc  api: allow keyword search in listSSHKeyPairs (#2920) (#3098)
a7ccbdc is described below

commit a7ccbdc79084b56d2a32a3ecd14d5ffed2b9a811
Author: Anurag Awasthi <43...@users.noreply.github.com>
AuthorDate: Sun Dec 23 00:34:53 2018 +0530

    api: allow keyword search in listSSHKeyPairs (#2920) (#3098)
    
    Adds support for keyword search that was ignored by listsshkeypairs command.
    
    Fixes: #2920
---
 server/src/com/cloud/server/ManagementServerImpl.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 56c912d..38a84bb 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -3655,6 +3655,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     public Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(final ListSSHKeyPairsCmd cmd) {
         final String name = cmd.getName();
         final String fingerPrint = cmd.getFingerprint();
+        final String keyword = cmd.getKeyword();
 
         final Account caller = getCaller();
         final List<Long> permittedAccounts = new ArrayList<Long>();
@@ -3681,6 +3682,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             sc.addAnd("fingerprint", SearchCriteria.Op.EQ, fingerPrint);
         }
 
+        if (keyword != null) {
+            sc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            sc.addOr("fingerprint", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+        }
+
         final Pair<List<SSHKeyPairVO>, Integer> result = _sshKeyPairDao.searchAndCount(sc, searchFilter);
         return new Pair<List<? extends SSHKeyPair>, Integer>(result.first(), result.second());
     }