CLOUDSTACK-1405: add scope type in liststoragepoolcmd
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
index 85a3c22..f33b987 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
@@ -64,6 +64,10 @@
             description="the ID of the storage pool")
     private Long id;
 
+    @Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING, entityType = StoragePoolResponse.class,
+            description="the ID of the storage pool")
+    private String scope;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -115,4 +119,8 @@
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }
+
+    public String getScope() {
+        return scope;
+    }
 }
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index ad29cda..c851e3b 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -55,6 +55,7 @@
 import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
 import org.apache.cloudstack.api.response.*;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
 import org.apache.cloudstack.query.QueryService;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -1862,6 +1863,14 @@
     }
 
     private Pair<List<StoragePoolJoinVO>, Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd) {
+        ScopeType scopeType = null;
+        if (cmd.getScope() != null) {
+            try {
+                scopeType = Enum.valueOf(ScopeType.class, cmd.getScope().toUpperCase());
+            } catch (Exception e) {
+                throw new InvalidParameterValueException("Invalid scope type: " + cmd.getScope());
+            }
+        }
 
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());       
         Object id = cmd.getId();
@@ -1922,6 +1931,9 @@
         if (cluster != null) {
             sc.setParameters("clusterId", cluster);
         }
+        if (scopeType != null) {
+            sc.setParameters("scope", scopeType.toString());
+        }
 
         // search Pool details by ids
         Pair<List<StoragePoolJoinVO>, Integer> uniquePoolPair = _poolJoinDao.searchAndCount(sc, searchFilter);