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 2020/02/28 09:35:59 UTC

[cloudstack] branch 4.13 updated: server: fix issue while list ssh keypairs by keyword (#3916)

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

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


The following commit(s) were added to refs/heads/4.13 by this push:
     new 79f7f0f  server: fix issue while list ssh keypairs by keyword (#3916)
79f7f0f is described below

commit 79f7f0f007e46a6a07f770e514d375d932a82966
Author: Wei Zhou <w....@global.leaseweb.com>
AuthorDate: Fri Feb 28 10:35:49 2020 +0100

    server: fix issue while list ssh keypairs by keyword (#3916)
    
    in 4.13, list sshkeypairs with keyword will ignore the search by name if name is specifed
    Fixes an issue in #3098
    
    for example,
    (local) > list sshkeypairs name=wei keyword=wei filter=name
    {
      "count": 3,
      "sshkeypair": [
        {
          "name": "wei3"
        },
        {
          "name": "wei2"
        },
        {
          "name": "wei"
        }
      ]
    }
    
    with this patch ,it gives correct result.
    
    (local) > list sshkeypairs name=wei keyword=wei filter=name
    {
      "count": 1,
      "sshkeypair": [
        {
          "name": "wei"
        }
      ]
    }
---
 server/src/main/java/com/cloud/server/ManagementServerImpl.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index 5bed8d6..31fc632 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -3747,8 +3747,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         }
 
         if (keyword != null) {
-            sc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-            sc.addOr("fingerprint", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            final SearchCriteria<SSHKeyPairVO> ssc = _sshKeyPairDao.createSearchCriteria();
+            ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            ssc.addOr("fingerprint", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            sc.addAnd("name", SearchCriteria.Op.SC, ssc);
         }
 
         final Pair<List<SSHKeyPairVO>, Integer> result = _sshKeyPairDao.searchAndCount(sc, searchFilter);