cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] git commit: CLOUDSTACK-332: intermediate checkin fixing count parameter in listCommands Fixes the count in commands:
Date Fri, 12 Oct 2012 21:01:34 GMT
Updated Branches:
  refs/heads/master 6e60a0756 -> 8f2d9a09e


CLOUDSTACK-332: intermediate checkin fixing count parameter in listCommands
Fixes the count in commands:

listVolumes
listVirtualMachines
listSnapshots
listRouters
listFirewallRules
listPortForwardingRules
listLoadBalancerRules
listIpForwardingRules
listAccounts
listUsers
listDomains
listDomainChildren
listPublicIpAddresses
listAlerts
listAsyncJobs
listRemoteAccessVpns
listVpnUsers
listTags
listPrivateGateways
listNetworkACLs
listStaticRoutes

Conflicts:

	api/src/com/cloud/api/commands/ListVMsCmd.java
	api/src/com/cloud/api/commands/ListVolumesCmd.java
	api/src/com/cloud/network/lb/LoadBalancingRulesService.java
	server/src/com/cloud/network/firewall/FirewallManagerImpl.java
	server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
	server/src/com/cloud/network/rules/RulesManagerImpl.java
	server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
	server/src/com/cloud/network/vpc/VpcManagerImpl.java
	server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
	server/src/com/cloud/tags/TaggedResourceManagerImpl.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8f2d9a09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8f2d9a09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8f2d9a09

Branch: refs/heads/master
Commit: 8f2d9a09e546e42a01b1cb7dceb2a7f129811a0d
Parents: 6e60a07
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Oct 12 12:52:28 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Oct 12 13:58:59 2012 -0700

----------------------------------------------------------------------
 .../com/cloud/api/commands/ListAccountsCmd.java    |    7 +-
 api/src/com/cloud/api/commands/ListAlertsCmd.java  |    7 +-
 .../com/cloud/api/commands/ListAsyncJobsCmd.java   |    7 +-
 .../cloud/api/commands/ListDomainChildrenCmd.java  |    7 +-
 api/src/com/cloud/api/commands/ListDomainsCmd.java |    7 +-
 .../cloud/api/commands/ListFirewallRulesCmd.java   |    7 +-
 .../api/commands/ListIpForwardingRulesCmd.java     |    9 +-
 .../api/commands/ListLoadBalancerRulesCmd.java     |    7 +-
 .../com/cloud/api/commands/ListNetworkACLsCmd.java |    7 +-
 .../api/commands/ListPortForwardingRulesCmd.java   |    7 +-
 .../cloud/api/commands/ListPrivateGatewaysCmd.java |    7 +-
 .../api/commands/ListPublicIpAddressesCmd.java     |    7 +-
 .../api/commands/ListRemoteAccessVpnsCmd.java      |    9 +-
 api/src/com/cloud/api/commands/ListRoutersCmd.java |    7 +-
 .../com/cloud/api/commands/ListSnapshotsCmd.java   |    7 +-
 .../cloud/api/commands/ListStaticRoutesCmd.java    |    7 +-
 api/src/com/cloud/api/commands/ListTagsCmd.java    |    7 +-
 api/src/com/cloud/api/commands/ListUsersCmd.java   |    7 +-
 api/src/com/cloud/api/commands/ListVMsCmd.java     |   10 +-
 api/src/com/cloud/api/commands/ListVolumesCmd.java |    7 +-
 .../com/cloud/api/commands/ListVpnUsersCmd.java    |    7 +-
 api/src/com/cloud/api/response/ListResponse.java   |   15 ++-
 .../cloud/network/firewall/FirewallService.java    |    4 +-
 .../cloud/network/firewall/NetworkACLService.java  |    4 +-
 .../network/lb/LoadBalancingRulesService.java      |    6 +-
 api/src/com/cloud/network/rules/RulesService.java  |    5 +-
 .../network/security/SecurityGroupService.java     |    4 +-
 api/src/com/cloud/network/vpc/VpcService.java      |    5 +-
 .../cloud/network/vpn/RemoteAccessVpnService.java  |    5 +-
 api/src/com/cloud/server/ManagementService.java    |    8 +-
 .../com/cloud/server/TaggedResourceService.java    |    3 +-
 api/src/com/cloud/storage/StorageService.java      |    3 +-
 .../cloud/storage/snapshot/SnapshotService.java    |    3 +-
 api/src/com/cloud/user/AccountService.java         |    4 +-
 api/src/com/cloud/user/DomainService.java          |    5 +-
 api/src/com/cloud/vm/UserVmService.java            |    3 +-
 server/src/com/cloud/api/ApiDBUtils.java           |    3 +-
 .../cloud/api/response/ApiResponseSerializer.java  |    4 +-
 .../network/firewall/FirewallManagerImpl.java      |    7 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |    7 +-
 .../com/cloud/network/rules/RulesManagerImpl.java  |   12 ++-
 .../cloud/network/vpc/NetworkACLManagerImpl.java   |    7 +-
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   24 ++--
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |   11 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   23 +++--
 .../src/com/cloud/storage/StorageManagerImpl.java  |    6 +-
 .../storage/snapshot/SnapshotManagerImpl.java      |    5 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |   98 ++++++++-------
 server/src/com/cloud/user/AccountManagerImpl.java  |   12 +-
 server/src/com/cloud/user/DomainManagerImpl.java   |   16 ++-
 server/src/com/cloud/vm/UserVmManager.java         |    4 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   14 ++-
 .../com/cloud/user/MockAccountManagerImpl.java     |    4 +-
 .../test/com/cloud/user/MockDomainManagerImpl.java |    5 +-
 .../test/com/cloud/vm/MockUserVmManagerImpl.java   |    4 +-
 server/test/com/cloud/vpc/MockVpcManagerImpl.java  |    5 +-
 utils/src/com/cloud/utils/db/GenericDao.java       |    9 ++
 utils/src/com/cloud/utils/db/GenericDaoBase.java   |   76 +++++++++++
 utils/src/com/cloud/utils/db/SqlGenerator.java     |    7 +
 59 files changed, 385 insertions(+), 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListAccountsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAccountsCmd.java b/api/src/com/cloud/api/commands/ListAccountsCmd.java
index eac7d1b..6e0a524 100755
--- a/api/src/com/cloud/api/commands/ListAccountsCmd.java
+++ b/api/src/com/cloud/api/commands/ListAccountsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.AccountResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists accounts and provides detailed account information for listed accounts", responseObject=AccountResponse.class)
 public class ListAccountsCmd extends BaseListDomainResourcesCmd {
@@ -91,15 +92,15 @@ public class ListAccountsCmd extends BaseListDomainResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends Account> accounts = _accountService.searchForAccounts(this);
+        Pair<List<? extends Account>, Integer> accounts = _accountService.searchForAccounts(this);
         ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
         List<AccountResponse> accountResponses = new ArrayList<AccountResponse>();
-        for (Account account : accounts) {
+        for (Account account : accounts.first()) {
             AccountResponse acctResponse = _responseGenerator.createAccountResponse(account);
             acctResponse.setObjectName("account");
             accountResponses.add(acctResponse);
         }
-        response.setResponses(accountResponses);
+        response.setResponses(accountResponses, accounts.second());
         response.setResponseName(getCommandName());
         
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListAlertsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAlertsCmd.java b/api/src/com/cloud/api/commands/ListAlertsCmd.java
index 1504093..1f6c7b3 100644
--- a/api/src/com/cloud/api/commands/ListAlertsCmd.java
+++ b/api/src/com/cloud/api/commands/ListAlertsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.response.AlertResponse;
 import com.cloud.api.response.ListResponse;
+import com.cloud.utils.Pair;
 
 @Implementation(description = "Lists all alerts.", responseObject = AlertResponse.class)
 public class ListAlertsCmd extends BaseListCmd {
@@ -71,10 +72,10 @@ public class ListAlertsCmd extends BaseListCmd {
 
     @Override
     public void execute() {
-        List<? extends Alert> result = _mgr.searchForAlerts(this);
+        Pair<List<? extends Alert>, Integer> result = _mgr.searchForAlerts(this);
         ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
         List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
-        for (Alert alert : result) {
+        for (Alert alert : result.first()) {
             AlertResponse alertResponse = new AlertResponse();
             alertResponse.setId(alert.getId());
             alertResponse.setAlertType(alert.getType());
@@ -85,7 +86,7 @@ public class ListAlertsCmd extends BaseListCmd {
             alertResponseList.add(alertResponse);
         }
 
-        response.setResponses(alertResponseList);
+        response.setResponses(alertResponseList, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListAsyncJobsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAsyncJobsCmd.java b/api/src/com/cloud/api/commands/ListAsyncJobsCmd.java
index bd6e80b..e0520cd 100644
--- a/api/src/com/cloud/api/commands/ListAsyncJobsCmd.java
+++ b/api/src/com/cloud/api/commands/ListAsyncJobsCmd.java
@@ -27,6 +27,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.AsyncJobResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.async.AsyncJob;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all pending asynchronous jobs for the account.", responseObject=AsyncJobResponse.class)
 public class ListAsyncJobsCmd extends BaseListAccountResourcesCmd {
@@ -58,14 +59,14 @@ public class ListAsyncJobsCmd extends BaseListAccountResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends AsyncJob> result = _mgr.searchForAsyncJobs(this);
+        Pair<List<? extends AsyncJob>, Integer> result = _mgr.searchForAsyncJobs(this);
         ListResponse<AsyncJobResponse> response = new ListResponse<AsyncJobResponse>();
         List<AsyncJobResponse> jobResponses = new ArrayList<AsyncJobResponse>();
-        for (AsyncJob job : result) {
+        for (AsyncJob job : result.first()) {
             jobResponses.add(_responseGenerator.createAsyncJobResponse(job));
         }
 
-        response.setResponses(jobResponses);
+        response.setResponses(jobResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListDomainChildrenCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListDomainChildrenCmd.java b/api/src/com/cloud/api/commands/ListDomainChildrenCmd.java
index d5b3f6c..bb0dd7f 100644
--- a/api/src/com/cloud/api/commands/ListDomainChildrenCmd.java
+++ b/api/src/com/cloud/api/commands/ListDomainChildrenCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.domain.Domain;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all children domains belonging to a specified domain", responseObject=DomainResponse.class)
 public class ListDomainChildrenCmd extends BaseListCmd {
@@ -84,16 +85,16 @@ public class ListDomainChildrenCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends Domain> result = _domainService.searchForDomainChildren(this);
+        Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomainChildren(this);
         ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
         List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
-        for (Domain domain : result) {
+        for (Domain domain : result.first()) {
             DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
             domainResponse.setObjectName("domain");
             domainResponses.add(domainResponse);
         }
 
-        response.setResponses(domainResponses);
+        response.setResponses(domainResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListDomainsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListDomainsCmd.java b/api/src/com/cloud/api/commands/ListDomainsCmd.java
index 9cefe9b..93d1570 100644
--- a/api/src/com/cloud/api/commands/ListDomainsCmd.java
+++ b/api/src/com/cloud/api/commands/ListDomainsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.domain.Domain;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists domains and provides detailed information for listed domains", responseObject=DomainResponse.class)
 public class ListDomainsCmd extends BaseListCmd {
@@ -84,16 +85,16 @@ public class ListDomainsCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends Domain> result = _domainService.searchForDomains(this);
+        Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomains(this);
         ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
         List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
-        for (Domain domain : result) {
+        for (Domain domain : result.first()) {
             DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
             domainResponse.setObjectName("domain");
             domainResponses.add(domainResponse);
         }
 
-        response.setResponses(domainResponses);
+        response.setResponses(domainResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java b/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
index 66dcc4d..c136266 100644
--- a/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
+++ b/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.FirewallResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.network.rules.FirewallRule;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all firewall rules for an IP address.", responseObject=FirewallResponse.class)
 public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
@@ -69,16 +70,16 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends FirewallRule> result = _firewallService.listFirewallRules(this);
+        Pair<List<? extends FirewallRule>, Integer> result = _firewallService.listFirewallRules(this);
         ListResponse<FirewallResponse> response = new ListResponse<FirewallResponse>();
         List<FirewallResponse> fwResponses = new ArrayList<FirewallResponse>();
         
-        for (FirewallRule fwRule : result) {
+        for (FirewallRule fwRule : result.first()) {
             FirewallResponse ruleData = _responseGenerator.createFirewallResponse(fwRule);
             ruleData.setObjectName("firewallrule");
             fwResponses.add(ruleData);
         }
-        response.setResponses(fwResponses);
+        response.setResponses(fwResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response); 
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java b/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java
index f385fe0..fedbac0 100644
--- a/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java
+++ b/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java
@@ -22,7 +22,6 @@ import java.util.List;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd.CommandType;
 import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
@@ -32,6 +31,7 @@ import com.cloud.api.response.IpForwardingRuleResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.StaticNatRule;
+import com.cloud.utils.Pair;
 
 @Implementation(description="List the ip forwarding rules", responseObject=FirewallRuleResponse.class)
 public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -82,17 +82,18 @@ public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResources
 
     @Override
     public void execute(){
-        List<? extends FirewallRule> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId(), this.isRecursive(), this.listAll());
+        Pair<List<? extends FirewallRule>, Integer> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, 
+                this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId(), this.isRecursive(), this.listAll());
         ListResponse<IpForwardingRuleResponse> response = new ListResponse<IpForwardingRuleResponse>();
         List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<IpForwardingRuleResponse>();
-        for (FirewallRule rule : result) {
+        for (FirewallRule rule : result.first()) {
             StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
             IpForwardingRuleResponse resp = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
             if (resp != null) {
                 ipForwardingResponses.add(resp);
             }
         }
-        response.setResponses(ipForwardingResponses);
+        response.setResponses(ipForwardingResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java b/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
index 43b0540..8413f60 100644
--- a/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
+++ b/api/src/com/cloud/api/commands/ListLoadBalancerRulesCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.LoadBalancerResponse;
 import com.cloud.network.rules.LoadBalancer;
+import com.cloud.utils.Pair;
 
 @Implementation(description = "Lists load balancer rules.", responseObject = LoadBalancerResponse.class)
 public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
@@ -94,17 +95,17 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
 
     @Override
     public void execute() {
-        List<? extends LoadBalancer> loadBalancers = _lbService.searchForLoadBalancers(this);
+        Pair<List<? extends LoadBalancer>, Integer> loadBalancers = _lbService.searchForLoadBalancers(this);
         ListResponse<LoadBalancerResponse> response = new ListResponse<LoadBalancerResponse>();
         List<LoadBalancerResponse> lbResponses = new ArrayList<LoadBalancerResponse>();
         if (loadBalancers != null) {
-            for (LoadBalancer loadBalancer : loadBalancers) {
+            for (LoadBalancer loadBalancer : loadBalancers.first()) {
                 LoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerResponse(loadBalancer);
                 lbResponse.setObjectName("loadbalancerrule");
                 lbResponses.add(lbResponse);
             }
         }
-        response.setResponses(lbResponses);
+        response.setResponses(lbResponses, loadBalancers.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListNetworkACLsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListNetworkACLsCmd.java b/api/src/com/cloud/api/commands/ListNetworkACLsCmd.java
index 3529558..bdb3c3b 100644
--- a/api/src/com/cloud/api/commands/ListNetworkACLsCmd.java
+++ b/api/src/com/cloud/api/commands/ListNetworkACLsCmd.java
@@ -31,6 +31,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.NetworkACLResponse;
 import com.cloud.network.rules.FirewallRule;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all network ACLs", responseObject=NetworkACLResponse.class)
 public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
@@ -79,15 +80,15 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends FirewallRule> result = _networkACLService.listNetworkACLs(this);
+        Pair<List<? extends FirewallRule>,Integer> result = _networkACLService.listNetworkACLs(this);
         ListResponse<NetworkACLResponse> response = new ListResponse<NetworkACLResponse>();
         List<NetworkACLResponse> aclResponses = new ArrayList<NetworkACLResponse>();
         
-        for (FirewallRule acl : result) {
+        for (FirewallRule acl : result.first()) {
             NetworkACLResponse ruleData = _responseGenerator.createNetworkACLResponse(acl);
             aclResponses.add(ruleData);
         }
-        response.setResponses(aclResponses);
+        response.setResponses(aclResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response); 
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java b/api/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java
index 499a574..0315a12 100644
--- a/api/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java
+++ b/api/src/com/cloud/api/commands/ListPortForwardingRulesCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.FirewallRuleResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.network.rules.PortForwardingRule;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all port forwarding rules for an IP address.", responseObject=FirewallRuleResponse.class)
 public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
@@ -71,16 +72,16 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends PortForwardingRule> result = _rulesService.listPortForwardingRules(this);
+        Pair<List<? extends PortForwardingRule>, Integer> result = _rulesService.listPortForwardingRules(this);
         ListResponse<FirewallRuleResponse> response = new ListResponse<FirewallRuleResponse>();
         List<FirewallRuleResponse> fwResponses = new ArrayList<FirewallRuleResponse>();
         
-        for (PortForwardingRule fwRule : result) {
+        for (PortForwardingRule fwRule : result.first()) {
             FirewallRuleResponse ruleData = _responseGenerator.createPortForwardingRuleResponse(fwRule);
             ruleData.setObjectName("portforwardingrule");
             fwResponses.add(ruleData);
         }
-        response.setResponses(fwResponses);
+        response.setResponses(fwResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response); 
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java b/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java
index 203d517..389df5e 100644
--- a/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java
+++ b/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.PrivateGatewayResponse;
 import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.utils.Pair;
 
 @Implementation(description="List private gateways", responseObject=PrivateGatewayResponse.class)
 public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCmd{
@@ -91,14 +92,14 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm
     
     @Override
     public void execute() {
-        List<PrivateGateway> gateways = _vpcService.listPrivateGateway(this);
+        Pair<List<PrivateGateway>, Integer> gateways = _vpcService.listPrivateGateway(this);
         ListResponse<PrivateGatewayResponse> response = new ListResponse<PrivateGatewayResponse>();
         List<PrivateGatewayResponse> projectResponses = new ArrayList<PrivateGatewayResponse>();
-        for (PrivateGateway gateway : gateways) {
+        for (PrivateGateway gateway : gateways.first()) {
             PrivateGatewayResponse gatewayResponse = _responseGenerator.createPrivateGatewayResponse(gateway);
             projectResponses.add(gatewayResponse);
         }
-        response.setResponses(projectResponses);
+        response.setResponses(projectResponses, gateways.second());
         response.setResponseName(getCommandName());
         
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java b/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java
index c6acf97..a49c5fe 100644
--- a/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java
+++ b/api/src/com/cloud/api/commands/ListPublicIpAddressesCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.IPAddressResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.network.IpAddress;
+import com.cloud.utils.Pair;
 
 
 @Implementation(description="Lists all public ip addresses", responseObject=IPAddressResponse.class)
@@ -141,16 +142,16 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends IpAddress> result = _mgr.searchForIPAddresses(this);
+        Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
         ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
         List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
-        for (IpAddress ipAddress : result) {
+        for (IpAddress ipAddress : result.first()) {
             IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress);
             ipResponse.setObjectName("publicipaddress");
             ipAddrResponses.add(ipResponse);
         }
 
-        response.setResponses(ipAddrResponses);
+        response.setResponses(ipAddrResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListRemoteAccessVpnsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListRemoteAccessVpnsCmd.java b/api/src/com/cloud/api/commands/ListRemoteAccessVpnsCmd.java
index 4260e3a..9dd1644 100644
--- a/api/src/com/cloud/api/commands/ListRemoteAccessVpnsCmd.java
+++ b/api/src/com/cloud/api/commands/ListRemoteAccessVpnsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.RemoteAccessVpnResponse;
 import com.cloud.network.RemoteAccessVpn;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists remote access vpns", responseObject=RemoteAccessVpnResponse.class)
 public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -64,15 +65,15 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC
 
     @Override
     public void execute(){
-        List<? extends RemoteAccessVpn> vpns = _ravService.searchForRemoteAccessVpns(this);
+        Pair<List<? extends RemoteAccessVpn>, Integer> vpns = _ravService.searchForRemoteAccessVpns(this);
         ListResponse<RemoteAccessVpnResponse> response = new ListResponse<RemoteAccessVpnResponse>();
         List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<RemoteAccessVpnResponse>();
-        if (vpns != null && !vpns.isEmpty()) {
-            for (RemoteAccessVpn vpn : vpns) {
+        if (vpns.first() != null && !vpns.first().isEmpty()) {
+            for (RemoteAccessVpn vpn : vpns.first()) {
                 vpnResponses.add(_responseGenerator.createRemoteAccessVpnResponse(vpn));
             }
         }
-        response.setResponses(vpnResponses);
+        response.setResponses(vpnResponses, vpns.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListRoutersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListRoutersCmd.java b/api/src/com/cloud/api/commands/ListRoutersCmd.java
index 72a9144..8bf9ba8 100644
--- a/api/src/com/cloud/api/commands/ListRoutersCmd.java
+++ b/api/src/com/cloud/api/commands/ListRoutersCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.DomainRouterResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.utils.Pair;
 
 @Implementation(description="List routers.", responseObject=DomainRouterResponse.class)
 public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -129,16 +130,16 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends VirtualRouter> result = _mgr.searchForRouters(this);
+        Pair<List<? extends VirtualRouter>, Integer> result = _mgr.searchForRouters(this);
         ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
         List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
-        for (VirtualRouter router : result) {
+        for (VirtualRouter router : result.first()) {
             DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
             routerResponse.setObjectName("router");
             routerResponses.add(routerResponse);
         }
 
-        response.setResponses(routerResponses);
+        response.setResponses(routerResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListSnapshotsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListSnapshotsCmd.java b/api/src/com/cloud/api/commands/ListSnapshotsCmd.java
index d7b2c9e..cc2aad8 100644
--- a/api/src/com/cloud/api/commands/ListSnapshotsCmd.java
+++ b/api/src/com/cloud/api/commands/ListSnapshotsCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.SnapshotResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.storage.Snapshot;
+import com.cloud.utils.Pair;
 
 
 @Implementation(description="Lists all available snapshots for the account.", responseObject=SnapshotResponse.class)
@@ -98,15 +99,15 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends Snapshot> result = _snapshotService.listSnapshots(this);
+        Pair<List<? extends Snapshot>, Integer> result = _snapshotService.listSnapshots(this);
         ListResponse<SnapshotResponse> response = new ListResponse<SnapshotResponse>();
         List<SnapshotResponse> snapshotResponses = new ArrayList<SnapshotResponse>();
-        for (Snapshot snapshot : result) {
+        for (Snapshot snapshot : result.first()) {
             SnapshotResponse snapshotResponse = _responseGenerator.createSnapshotResponse(snapshot);
             snapshotResponse.setObjectName("snapshot");
             snapshotResponses.add(snapshotResponse);
         }
-        response.setResponses(snapshotResponses);
+        response.setResponses(snapshotResponses, result.second());
         response.setResponseName(getCommandName());
         
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java b/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
index 3cd8286..93b533e 100644
--- a/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
+++ b/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
@@ -26,6 +26,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.StaticRouteResponse;
 import com.cloud.network.vpc.StaticRoute;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all static routes", responseObject=StaticRouteResponse.class)
 public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
@@ -68,15 +69,15 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends StaticRoute> result = _vpcService.listStaticRoutes(this);
+        Pair<List<? extends StaticRoute>, Integer> result = _vpcService.listStaticRoutes(this);
         ListResponse<StaticRouteResponse> response = new ListResponse<StaticRouteResponse>();
         List<StaticRouteResponse> routeResponses = new ArrayList<StaticRouteResponse>();
         
-        for (StaticRoute route : result) {
+        for (StaticRoute route : result.first()) {
             StaticRouteResponse ruleData = _responseGenerator.createStaticRouteResponse(route);
             routeResponses.add(ruleData);
         }
-        response.setResponses(routeResponses);
+        response.setResponses(routeResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response); 
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListTagsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListTagsCmd.java b/api/src/com/cloud/api/commands/ListTagsCmd.java
index 7206b1c..b832b42 100644
--- a/api/src/com/cloud/api/commands/ListTagsCmd.java
+++ b/api/src/com/cloud/api/commands/ListTagsCmd.java
@@ -27,6 +27,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.ResourceTagResponse;
 import com.cloud.server.ResourceTag;
+import com.cloud.utils.Pair;
 
 @Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
 public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
@@ -55,14 +56,14 @@ public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
     @Override
     public void execute() {
       
-      List<? extends ResourceTag> tags = _taggedResourceService.listTags(this);
+      Pair<List<? extends ResourceTag>, Integer> tags = _taggedResourceService.listTags(this);
       ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
       List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
-      for (ResourceTag tag : tags) {
+      for (ResourceTag tag : tags.first()) {
           ResourceTagResponse tagResponse = _responseGenerator.createResourceTagResponse(tag, false);
           tagResponses.add(tagResponse);
       }
-      response.setResponses(tagResponses);
+      response.setResponses(tagResponses, tags.second());
       
       response.setResponseName(getCommandName());
       this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListUsersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListUsersCmd.java b/api/src/com/cloud/api/commands/ListUsersCmd.java
index ec3a1bb..03db56d 100644
--- a/api/src/com/cloud/api/commands/ListUsersCmd.java
+++ b/api/src/com/cloud/api/commands/ListUsersCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.UserResponse;
 import com.cloud.user.UserAccount;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists user accounts", responseObject=UserResponse.class)
 public class ListUsersCmd extends BaseListAccountResourcesCmd {
@@ -85,14 +86,14 @@ public class ListUsersCmd extends BaseListAccountResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends UserAccount> result = _accountService.searchForUsers(this);
+        Pair<List<? extends UserAccount>, Integer> result = _accountService.searchForUsers(this);
         ListResponse<UserResponse> response = new ListResponse<UserResponse>();
         List<UserResponse> userResponses = new ArrayList<UserResponse>();
-        for (UserAccount user : result) {
+        for (UserAccount user : result.first()) {
             UserResponse userResponse = _responseGenerator.createUserResponse(user);
             userResponses.add(userResponse);
         }
-        response.setResponses(userResponses);
+        response.setResponses(userResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListVMsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVMsCmd.java b/api/src/com/cloud/api/commands/ListVMsCmd.java
index 37dfcd3..2f6f988 100755
--- a/api/src/com/cloud/api/commands/ListVMsCmd.java
+++ b/api/src/com/cloud/api/commands/ListVMsCmd.java
@@ -33,6 +33,8 @@ import com.cloud.api.response.UserVmResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
+
 
 @Implementation(description="List the virtual machines owned by the account.", responseObject=UserVmResponse.class)
 public class ListVMsCmd extends BaseListTaggedResourcesCmd {
@@ -197,17 +199,17 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
 
 	@Override
     public void execute(){
-        List<? extends UserVm> result = _userVmService.searchForUserVMs(this);
+        Pair<List<? extends UserVm>, Integer> result = _userVmService.searchForUserVMs(this);
         ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
         EnumSet<VMDetails> details = getDetails();
         List<UserVmResponse> vmResponses;
         if (details.contains(VMDetails.all)){ // for all use optimized version
-        	 vmResponses = _responseGenerator.createUserVmResponse("virtualmachine", result.toArray(new UserVm[result.size()]));
+            vmResponses = _responseGenerator.createUserVmResponse("virtualmachine", result.first().toArray(new UserVm[result.first().size()]));
         }
         else {
-        	 vmResponses = _responseGenerator.createUserVmResponse("virtualmachine", getDetails(), result.toArray(new UserVm[result.size()]));
+        	 vmResponses = _responseGenerator.createUserVmResponse("virtualmachine", getDetails(), result.first().toArray(new UserVm[result.first().size()]));
         }
-        response.setResponses(vmResponses);
+        response.setResponses(vmResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListVolumesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVolumesCmd.java b/api/src/com/cloud/api/commands/ListVolumesCmd.java
index e0393a9..7875c83 100755
--- a/api/src/com/cloud/api/commands/ListVolumesCmd.java
+++ b/api/src/com/cloud/api/commands/ListVolumesCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.VolumeResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.storage.Volume;
+import com.cloud.utils.Pair;
 
 
 @Implementation(description="Lists all volumes.", responseObject=VolumeResponse.class)
@@ -117,17 +118,17 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends Volume> volumes = _storageService.searchForVolumes(this);
+        Pair<List<? extends Volume>, Integer> volumes = _storageService.searchForVolumes(this);
 
         ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
         List<VolumeResponse> volResponses = new ArrayList<VolumeResponse>();
-        for (Volume volume : volumes) {
+        for (Volume volume : volumes.first()) {
             VolumeResponse volResponse = _responseGenerator.createVolumeResponse(volume);
             volResponse.setObjectName("volume");
             volResponses.add(volResponse);
         }
 
-        response.setResponses(volResponses);
+        response.setResponses(volResponses, volumes.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/commands/ListVpnUsersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVpnUsersCmd.java b/api/src/com/cloud/api/commands/ListVpnUsersCmd.java
index 9bc77ff..9280ed5 100644
--- a/api/src/com/cloud/api/commands/ListVpnUsersCmd.java
+++ b/api/src/com/cloud/api/commands/ListVpnUsersCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.VpnUsersResponse;
 import com.cloud.network.VpnUser;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists vpn users", responseObject=VpnUsersResponse.class)
 public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -69,15 +70,15 @@ public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd {
     
     @Override
     public void execute(){
-        List<? extends VpnUser> vpnUsers = _ravService.searchForVpnUsers(this);
+        Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
 
         ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
         List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
-        for (VpnUser vpnUser : vpnUsers) {
+        for (VpnUser vpnUser : vpnUsers.first()) {
             vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
         }
 
-        response.setResponses(vpnResponses);
+        response.setResponses(vpnResponses, vpnUsers.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/api/response/ListResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/ListResponse.java b/api/src/com/cloud/api/response/ListResponse.java
index 47f76a5..ebba402 100644
--- a/api/src/com/cloud/api/response/ListResponse.java
+++ b/api/src/com/cloud/api/response/ListResponse.java
@@ -22,6 +22,7 @@ import com.cloud.api.ResponseObject;
 
 public class ListResponse<T extends ResponseObject> extends BaseResponse {
     List<T> responses;
+    private transient Integer count;
 
     public List<T> getResponses() {
         return responses;
@@ -30,12 +31,22 @@ public class ListResponse<T extends ResponseObject> extends BaseResponse {
     public void setResponses(List<T> responses) {
         this.responses = responses;
     }
+    
+    public void setResponses(List<T> responses, Integer count) {
+        this.responses = responses;
+        this.count = count;
+    }
+    
 
     public Integer getCount() {
+        if (count != null) {
+            return count;
+        }
+        
         if (responses != null) {
             return responses.size();
-        } else {
-            return null;
         }
+        
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/firewall/FirewallService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/firewall/FirewallService.java b/api/src/com/cloud/network/firewall/FirewallService.java
index 6eb9f99..07c2fb5 100644
--- a/api/src/com/cloud/network/firewall/FirewallService.java
+++ b/api/src/com/cloud/network/firewall/FirewallService.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.firewall;
 
+
 import java.util.List;
 
 import com.cloud.api.commands.ListFirewallRulesCmd;
@@ -23,11 +24,12 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 public interface FirewallService {
     FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
 
-    List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd);
+    Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewallRulesCmd cmd);
 
     /**
      * Revokes a firewall rule

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/firewall/NetworkACLService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/firewall/NetworkACLService.java b/api/src/com/cloud/network/firewall/NetworkACLService.java
index 1977088..10896b6 100644
--- a/api/src/com/cloud/network/firewall/NetworkACLService.java
+++ b/api/src/com/cloud/network/firewall/NetworkACLService.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.firewall;
 
+
 import java.util.List;
 
 import com.cloud.api.commands.ListNetworkACLsCmd;
@@ -23,6 +24,7 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 public interface NetworkACLService {
     FirewallRule getNetworkACL(long ruleId);
@@ -43,6 +45,6 @@ public interface NetworkACLService {
      * @param listNetworkACLsCmd
      * @return
      */
-    List<? extends FirewallRule> listNetworkACLs(ListNetworkACLsCmd cmd);
+    Pair<List<? extends FirewallRule>, Integer> listNetworkACLs(ListNetworkACLsCmd cmd);
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index d30195d..0cf2ef9 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -30,6 +30,8 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.rules.LoadBalancer;
 import com.cloud.network.rules.StickinessPolicy;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
+
 
 public interface LoadBalancingRulesService {
     /**
@@ -90,7 +92,7 @@ public interface LoadBalancingRulesService {
      *            by id, name, public ip, and vm instance id
      * @return list of load balancers that match the criteria
      */
-    List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
+    Pair<List<? extends LoadBalancer>, Integer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
 
     /**
      * List stickiness policies based on the given criteria
@@ -105,4 +107,4 @@ public interface LoadBalancingRulesService {
 
     LoadBalancer findById(long LoadBalancer);
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/rules/RulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java
index 9dd602b..8eadfba 100644
--- a/api/src/com/cloud/network/rules/RulesService.java
+++ b/api/src/com/cloud/network/rules/RulesService.java
@@ -23,9 +23,10 @@ import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 public interface RulesService {
-    List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll);
+    Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll);
 
     /**
      * Creates a port forwarding rule between two ip addresses or between
@@ -60,7 +61,7 @@ public interface RulesService {
      *            the command object holding the criteria for listing port forwarding rules (the ipAddress)
      * @return list of port forwarding rules on the given address, empty list if no rules exist
      */
-    public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
+    public Pair<List<? extends PortForwardingRule>, Integer> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
 
     boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/security/SecurityGroupService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/security/SecurityGroupService.java b/api/src/com/cloud/network/security/SecurityGroupService.java
index bace6bb..4a4b171 100644
--- a/api/src/com/cloud/network/security/SecurityGroupService.java
+++ b/api/src/com/cloud/network/security/SecurityGroupService.java
@@ -18,13 +18,13 @@ package com.cloud.network.security;
 
 import java.util.List;
 
-import com.cloud.api.commands.AuthorizeSecurityGroupIngressCmd;
 import com.cloud.api.commands.AuthorizeSecurityGroupEgressCmd;
+import com.cloud.api.commands.AuthorizeSecurityGroupIngressCmd;
 import com.cloud.api.commands.CreateSecurityGroupCmd;
 import com.cloud.api.commands.DeleteSecurityGroupCmd;
 import com.cloud.api.commands.ListSecurityGroupsCmd;
-import com.cloud.api.commands.RevokeSecurityGroupIngressCmd;
 import com.cloud.api.commands.RevokeSecurityGroupEgressCmd;
+import com.cloud.api.commands.RevokeSecurityGroupIngressCmd;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceInUseException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index 7d8de55..c13e37f 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -34,6 +34,7 @@ import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
 import com.cloud.user.Account;
 import com.cloud.user.User;
+import com.cloud.utils.Pair;
 
 public interface VpcService {
     
@@ -190,7 +191,7 @@ public interface VpcService {
      * @param listPrivateGatewaysCmd
      * @return
      */
-    public List<PrivateGateway> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);
+    public Pair<List<PrivateGateway>, Integer> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);
 
     /**
      * @param routeId
@@ -223,7 +224,7 @@ public interface VpcService {
      * @param listStaticRoutesCmd
      * @return
      */
-    public List<? extends StaticRoute> listStaticRoutes(ListStaticRoutesCmd cmd);
+    public Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(ListStaticRoutesCmd cmd);
 
     /**
      * @param id

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
index b2fb34b..2f95637 100644
--- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
+++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
@@ -24,6 +24,7 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.VpnUser;
+import com.cloud.utils.Pair;
 
 public interface RemoteAccessVpnService {
 
@@ -37,8 +38,8 @@ public interface RemoteAccessVpnService {
     List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);
     boolean applyVpnUsers(long vpnOwnerId, String userName);
     
-    List<? extends RemoteAccessVpn> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);
-    List<? extends VpnUser> searchForVpnUsers(ListVpnUsersCmd cmd);
+    Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);
+    Pair<List<? extends VpnUser>, Integer> searchForVpnUsers(ListVpnUsersCmd cmd);
     
     List<? extends RemoteAccessVpn> listRemoteAccessVpns(long networkId);
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 8dcc398..d1a789e 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -184,7 +184,7 @@ public interface ManagementService {
      * @param cmd
      * @return List of DomainRouters.
      */
-    List<? extends VirtualRouter> searchForRouters(ListRoutersCmd cmd);
+    Pair<List<? extends VirtualRouter>, Integer> searchForRouters(ListRoutersCmd cmd);
 
     /**
      * Obtains a list of IP Addresses by the specified search criteria. Can search by: "userId", "dataCenterId",
@@ -194,7 +194,7 @@ public interface ManagementService {
      *            the command that wraps the search criteria
      * @return List of IPAddresses
      */
-    List<? extends IpAddress> searchForIPAddresses(ListPublicIpAddressesCmd cmd);
+    Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd);
 
     /**
      * Obtains a list of all guest OS.
@@ -235,7 +235,7 @@ public interface ManagementService {
      * @param c
      * @return List of Alerts
      */
-    List<? extends Alert> searchForAlerts(ListAlertsCmd cmd);
+    Pair<List<? extends Alert>, Integer> searchForAlerts(ListAlertsCmd cmd);
 
     /**
      * list all the capacity rows in capacity operations table
@@ -363,7 +363,7 @@ public interface ManagementService {
      *            the command specifying the account and start date parameters
      * @return the list of async jobs that match the criteria
      */
-    List<? extends AsyncJob> searchForAsyncJobs(ListAsyncJobsCmd cmd);
+    Pair<List<? extends AsyncJob>, Integer> searchForAsyncJobs(ListAsyncJobsCmd cmd);
 
     /**
      * Generates a random password that will be used (initially) by newly created and started virtual machines

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/server/TaggedResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/TaggedResourceService.java b/api/src/com/cloud/server/TaggedResourceService.java
index dd1b1c6..dce799e 100644
--- a/api/src/com/cloud/server/TaggedResourceService.java
+++ b/api/src/com/cloud/server/TaggedResourceService.java
@@ -21,6 +21,7 @@ import java.util.Map;
 
 import com.cloud.api.commands.ListTagsCmd;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.utils.Pair;
 
 public interface TaggedResourceService {
     
@@ -46,7 +47,7 @@ public interface TaggedResourceService {
      * @param listTagsCmd
      * @return
      */
-    List<? extends ResourceTag> listTags(ListTagsCmd listTagsCmd);
+    Pair<List<? extends ResourceTag>, Integer> listTags(ListTagsCmd listTagsCmd);
 
     /**
      * @param resourceIds

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/storage/StorageService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StorageService.java b/api/src/com/cloud/storage/StorageService.java
index 4fb3b55..1649e15 100644
--- a/api/src/com/cloud/storage/StorageService.java
+++ b/api/src/com/cloud/storage/StorageService.java
@@ -32,6 +32,7 @@ import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.utils.Pair;
 
 public interface StorageService{
     /**
@@ -114,7 +115,7 @@ public interface StorageService{
 
     Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
 
-    List<? extends Volume> searchForVolumes(ListVolumesCmd cmd);
+    Pair<List<? extends Volume>, Integer> searchForVolumes(ListVolumesCmd cmd);
 
     /**
      * Uploads the volume to secondary storage

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/storage/snapshot/SnapshotService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/snapshot/SnapshotService.java b/api/src/com/cloud/storage/snapshot/SnapshotService.java
index 0c0e9b6..84388e9 100644
--- a/api/src/com/cloud/storage/snapshot/SnapshotService.java
+++ b/api/src/com/cloud/storage/snapshot/SnapshotService.java
@@ -28,6 +28,7 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.Volume;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 public interface SnapshotService {
 
@@ -39,7 +40,7 @@ public interface SnapshotService {
      * @return list of snapshots
      * @throws PermissionDeniedException
      */
-    List<? extends Snapshot> listSnapshots(ListSnapshotsCmd cmd);
+    Pair<List<? extends Snapshot>, Integer> listSnapshots(ListSnapshotsCmd cmd);
 
     /**
      * Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index 53383d3..90e3551 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -191,9 +191,9 @@ public interface AccountService {
 
     public String[] createApiKeyAndSecretKey(RegisterCmd cmd);
 
-    List<? extends Account> searchForAccounts(ListAccountsCmd cmd);
+    Pair<List<? extends Account>, Integer> searchForAccounts(ListAccountsCmd cmd);
 
-    List<? extends UserAccount> searchForUsers(ListUsersCmd cmd)
+    Pair<List<? extends UserAccount>, Integer> searchForUsers(ListUsersCmd cmd)
             throws PermissionDeniedException;
 
     UserAccount getUserByApiKey(String apiKey);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/user/DomainService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/DomainService.java b/api/src/com/cloud/user/DomainService.java
index 362f87e..83f3622 100644
--- a/api/src/com/cloud/user/DomainService.java
+++ b/api/src/com/cloud/user/DomainService.java
@@ -22,6 +22,7 @@ import com.cloud.api.commands.ListDomainChildrenCmd;
 import com.cloud.api.commands.ListDomainsCmd;
 import com.cloud.domain.Domain;
 import com.cloud.exception.PermissionDeniedException;
+import com.cloud.utils.Pair;
 
 public interface DomainService {
 
@@ -39,10 +40,10 @@ public interface DomainService {
 
     boolean deleteDomain(long domainId, Boolean cleanup);
 
-    List<? extends Domain> searchForDomains(ListDomainsCmd cmd)
+    Pair<List<? extends Domain>, Integer> searchForDomains(ListDomainsCmd cmd)
             throws PermissionDeniedException;
 
-    List<? extends Domain> searchForDomainChildren(ListDomainChildrenCmd cmd)
+    Pair<List<? extends Domain>, Integer> searchForDomainChildren(ListDomainChildrenCmd cmd)
             throws PermissionDeniedException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index 6635657..02682b0 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -53,6 +53,7 @@ import com.cloud.storage.Volume;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
 import com.cloud.utils.exception.ExecutionException;
 
 public interface UserVmService {
@@ -378,7 +379,7 @@ public interface UserVmService {
      *            the API command that wraps the search criteria
      * @return List of UserVMs.
      */
-    List<? extends UserVm> searchForUserVMs(ListVMsCmd cmd);
+    Pair<List<? extends UserVm>, Integer> searchForUserVMs(ListVMsCmd cmd);
 
     HypervisorType getHypervisorTypeOfUserVM(long vmid);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 3fac7a7..1d6ba4f 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -322,7 +322,8 @@ public class ApiDBUtils {
     }
 
     public static List<UserVmVO> searchForUserVMs(Criteria c, List<Long> permittedAccounts) {
-        return _userVmMgr.searchForUserVMs(c, _accountDao.findById(Account.ACCOUNT_ID_SYSTEM), null, false, permittedAccounts, false, null, null);
+        return _userVmMgr.searchForUserVMs(c, _accountDao.findById(Account.ACCOUNT_ID_SYSTEM),
+                null, false, permittedAccounts, false, null, null).first();
     }
 
     public static List<? extends StoragePoolVO> searchForStoragePools(Criteria c) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/api/response/ApiResponseSerializer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/response/ApiResponseSerializer.java b/server/src/com/cloud/api/response/ApiResponseSerializer.java
index 124bee1..1429d14 100644
--- a/server/src/com/cloud/api/response/ApiResponseSerializer.java
+++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java
@@ -80,9 +80,9 @@ public class ApiResponseSerializer {
                     jsonStr = unescape(jsonStr);
 
                     if (count != null && count != 0) {
-                        sb.append("{ \"" + ApiConstants.COUNT + "\":" + ((ListResponse) result).getCount() + " ,\"" + responses.get(0).getObjectName() + "\" : [  " + jsonStr);
+                        sb.append("{ \"" + ApiConstants.COUNT + "\":" + count + " ,\"" + responses.get(0).getObjectName() + "\" : [  " + jsonStr);
                     }
-                    for (int i = 1; i < count; i++) {
+                    for (int i = 1; i < ((ListResponse) result).getResponses().size(); i++) {
                         jsonStr = gson.toJson(responses.get(i));
                         jsonStr = unescape(jsonStr);
                         sb.append(", " + jsonStr);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index 82aa9d2..6e3805b 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -66,6 +66,8 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.DomainManager;
 import com.cloud.user.UserContext;
+import com.cloud.utils.IdentityProxy;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -206,7 +208,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
     }
 
     @Override
-    public List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd) {
+    public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewallRulesCmd cmd) {
         Long ipId = cmd.getIpAddressId();
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
@@ -272,7 +274,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
 
         sc.setParameters("purpose", Purpose.Firewall);
 
-        return _firewallDao.search(sc, filter);
+        Pair<List<FirewallRuleVO>, Integer> result = _firewallDao.searchAndCount(sc, filter);
+        return new Pair<List<? extends FirewallRule>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index ba9923f..ba4b097 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -95,6 +95,8 @@ import com.cloud.user.DomainService;
 import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.IdentityProxy;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -1237,7 +1239,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
     }
 
     @Override
-    public List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd) {
+    public Pair<List<? extends LoadBalancer>, Integer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd) {
         Long ipId = cmd.getPublicIpId();
         Long zoneId = cmd.getZoneId();
         Long id = cmd.getId();
@@ -1328,7 +1330,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
             }
         }
 
-        return _lbDao.search(sc, searchFilter);
+        Pair<List<LoadBalancerVO>, Integer> result = _lbDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends LoadBalancer>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 2383366..a4e0722 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -61,6 +61,8 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.DomainManager;
 import com.cloud.user.UserContext;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.IdentityProxy;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -686,7 +688,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
     }
 
     @Override
-    public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd) {
+    public Pair<List<? extends PortForwardingRule>, Integer> listPortForwardingRules(ListPortForwardingRulesCmd cmd) {
         Long ipId = cmd.getIpAddressId();
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
@@ -752,7 +754,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
 
         sc.setParameters("purpose", Purpose.PortForwarding);
 
-        return _portForwardingDao.search(sc, filter);
+        Pair<List<PortForwardingRuleVO>, Integer> result = _portForwardingDao.searchAndCount(sc, filter);
+        return new Pair<List<? extends PortForwardingRule>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -902,7 +905,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
     }
 
     @Override
-    public List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll) {
+    public Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll) {
         Account caller = UserContext.current().getCaller();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
@@ -950,7 +953,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
             sc.setJoinParameters("ipSearch", "associatedWithVmId", vmId);
         }
 
-        return _firewallDao.search(sc, filter);
+        Pair<List<FirewallRuleVO>, Integer> result = _firewallDao.searchAndCount(sc, filter);
+        return new Pair<List<? extends FirewallRule>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index e3483a0..ce1b768 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -51,6 +51,8 @@ import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.UserContext;
+import com.cloud.utils.IdentityProxy;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -346,7 +348,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
 
     
     @Override
-    public List<? extends FirewallRule> listNetworkACLs(ListNetworkACLsCmd cmd) {
+    public Pair<List<? extends FirewallRule>,Integer> listNetworkACLs(ListNetworkACLsCmd cmd) {
         Long networkId = cmd.getNetworkId();
         Long id = cmd.getId();
         String trafficType = cmd.getTrafficType();
@@ -411,7 +413,8 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
 
         sc.setParameters("purpose", Purpose.NetworkACL);
 
-        return _firewallDao.search(sc, filter);
+        Pair<List<FirewallRuleVO>, Integer> result = _firewallDao.searchAndCount(sc, filter);
+        return new Pair<List<? extends FirewallRule>, Integer>(result.first(), result.second());
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 675ae59..987bd45 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -95,6 +95,7 @@ import com.cloud.user.ResourceLimitService;
 import com.cloud.user.User;
 import com.cloud.user.UserContext;
 import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.component.Inject;
@@ -1387,7 +1388,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
     }
 
     @Override
-    public List<PrivateGateway> listPrivateGateway(ListPrivateGatewaysCmd cmd) {
+    public Pair<List<PrivateGateway>, Integer> listPrivateGateway(ListPrivateGatewaysCmd cmd) {
         String ipAddress = cmd.getIpAddress();
         String vlan = cmd.getVlan();
         Long vpcId = cmd.getVpcId();
@@ -1441,14 +1442,14 @@ public class VpcManagerImpl implements VpcManager, Manager{
         if (vlan != null) {
             sc.setJoinParameters("networkSearch", "vlan", BroadcastDomainType.Vlan.toUri(vlan));
         }
-       
-        List<VpcGatewayVO> vos = _vpcGatewayDao.search(sc, searchFilter);
-        List<PrivateGateway> privateGtws = new ArrayList<PrivateGateway>(vos.size());
-        for (VpcGateway vo : vos) {
+
+        Pair<List<VpcGatewayVO>, Integer> vos = _vpcGatewayDao.searchAndCount(sc, searchFilter);
+        List<PrivateGateway> privateGtws = new ArrayList<PrivateGateway>(vos.first().size());
+        for (VpcGateway vo : vos.first()) {
             privateGtws.add(getPrivateGatewayProfile(vo));
         }
-        
-        return privateGtws;
+
+        return new Pair<List<PrivateGateway>, Integer>(privateGtws, vos.second());
     }
     
     @Override
@@ -1608,7 +1609,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
     }
 
     @Override
-    public List<? extends StaticRoute> listStaticRoutes(ListStaticRoutesCmd cmd) {
+    public Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(ListStaticRoutesCmd cmd) {
         Long id = cmd.getId();
         Long gatewayId = cmd.getGatewayId();
         Long vpcId = cmd.getVpcId();
@@ -1673,10 +1674,11 @@ public class VpcManagerImpl implements VpcManager, Manager{
                 count++;
             }   
         }
-        
-        return _staticRouteDao.search(sc, searchFilter);
+
+        Pair<List<StaticRouteVO>, Integer> result = _staticRouteDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends StaticRoute>, Integer>(result.first(), result.second());
     }
-    
+
     protected void detectRoutesConflict(StaticRoute newRoute) throws NetworkRuleConflictException {
         List<? extends StaticRoute> routes = _staticRouteDao.listByGatewayIdAndNotRevoked(newRoute.getVpcGatewayId());
         assert (routes.size() >= 1) : "For static routes, we now always first persist the route and then check for " +

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index c01dc6e..0556e8e 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -497,10 +497,9 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
     }
 
     @Override
-    public List<VpnUserVO> searchForVpnUsers(ListVpnUsersCmd cmd) {
+    public Pair<List<? extends VpnUser>, Integer> searchForVpnUsers(ListVpnUsersCmd cmd) {
         String username = cmd.getUsername();
         Long id = cmd.getId();
-        
         Account caller = UserContext.current().getCaller();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
@@ -532,11 +531,12 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
             sc.setParameters("username", username);
         }
 
-        return _vpnUsersDao.search(sc, searchFilter);
+        Pair<List<VpnUserVO>, Integer> result = _vpnUsersDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends VpnUser>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) {
+    public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) {
         // do some parameter validation
         Account caller = UserContext.current().getCaller();
         Long ipAddressId = cmd.getPublicIpId();
@@ -579,7 +579,8 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
             sc.setParameters("serverAddressId", ipAddressId);
         }
 
-        return _remoteAccessVpnDao.search(sc, filter);
+        Pair<List<RemoteAccessVpnVO>, Integer> result = _remoteAccessVpnDao.searchAndCount(sc, filter);
+        return new Pair<List<? extends RemoteAccessVpn>, Integer> (result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index d043ab1..a698c93 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -98,6 +98,7 @@ import com.cloud.api.commands.UpdateVMGroupCmd;
 import com.cloud.api.commands.UpgradeSystemVMCmd;
 import com.cloud.api.commands.UploadCustomCertificateCmd;
 import com.cloud.api.response.ExtractResponse;
+import com.cloud.async.AsyncJob;
 import com.cloud.async.AsyncJobExecutor;
 import com.cloud.async.AsyncJobManager;
 import com.cloud.async.AsyncJobResult;
@@ -159,11 +160,13 @@ import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
 import com.cloud.info.ConsoleProxyInfo;
 import com.cloud.keystore.KeystoreManager;
 import com.cloud.network.IPAddressVO;
+import com.cloud.network.IpAddress;
 import com.cloud.network.LoadBalancerVO;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.router.VirtualRouter;
 import com.cloud.org.Cluster;
 import com.cloud.org.Grouping.AllocationState;
 import com.cloud.projects.Project;
@@ -1612,7 +1615,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<DomainRouterVO> searchForRouters(ListRoutersCmd cmd) {
+    public Pair<List<? extends VirtualRouter>, Integer> searchForRouters(ListRoutersCmd cmd) {
         Long id = cmd.getId();
         String name = cmd.getRouterName();
         String state = cmd.getState();
@@ -1707,11 +1710,12 @@ public class ManagementServerImpl implements ManagementServer {
             sc.setParameters("vpcId", vpcId);
         }
 
-        return _routerDao.search(sc, searchFilter);
+        Pair<List<DomainRouterVO>, Integer> result = _routerDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends VirtualRouter>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<IPAddressVO> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
+    public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
         Object keyword = cmd.getKeyword();
         Long physicalNetworkId = cmd.getPhysicalNetworkId();
         Long associatedNetworkId = cmd.getAssociatedNetworkId();
@@ -1858,7 +1862,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
         }
 
-        return _publicIpAddressDao.search(sc, searchFilter);
+        Pair<List<IPAddressVO>, Integer> result = _publicIpAddressDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends IpAddress>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -2076,7 +2081,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<? extends Alert> searchForAlerts(ListAlertsCmd cmd) {
+    public Pair<List<? extends Alert>, Integer> searchForAlerts(ListAlertsCmd cmd) {
         Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchCriteria<AlertVO> sc = _alertDao.createSearchCriteria();
 
@@ -2103,7 +2108,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("type", SearchCriteria.Op.EQ, type);
         }
 
-        return _alertDao.search(sc, searchFilter);
+        Pair<List<AlertVO>, Integer> result =_alertDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Alert>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -2539,7 +2545,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd) {
+    public Pair<List<? extends AsyncJob>, Integer> searchForAsyncJobs(ListAsyncJobsCmd cmd) {
 
         Account caller = UserContext.current().getCaller();
 
@@ -2609,7 +2615,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("created", SearchCriteria.Op.GTEQ, startDate);
         }
 
-        return _jobDao.search(sc, searchFilter);
+        Pair<List<AsyncJobVO>, Integer> result = _jobDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends AsyncJob>, Integer> (result.first(), result.second());
     }
 
     @ActionEvent(eventType = EventTypes.EVENT_SSVM_START, eventDescription = "starting secondary storage Vm", async = true)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index fc6fb5b..7ec50f9 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -3825,7 +3825,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
     }
 
     @Override
-    public List<VolumeVO> searchForVolumes(ListVolumesCmd cmd) {
+    public Pair<List<? extends Volume>, Integer> searchForVolumes(ListVolumesCmd cmd) {
         Account caller = UserContext.current().getCaller();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
@@ -3937,8 +3937,10 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         // Only return volumes that are not destroyed
         sc.setParameters("state", Volume.State.Destroy);
+        
+        Pair<List<VolumeVO>, Integer> volumes = _volumeDao.searchAndCount(sc, searchFilter);
 
-        return _volumeDao.search(sc, searchFilter);
+        return new Pair<List<? extends Volume>, Integer>(volumes.first(), volumes.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f2d9a09/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 2410d08..32e37e6 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -853,7 +853,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
     }
 
     @Override
-    public List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd) {
+    public Pair<List<? extends Snapshot>, Integer> listSnapshots(ListSnapshotsCmd cmd) {
         Long volumeId = cmd.getVolumeId();
         String name = cmd.getSnapshotName();
         Long id = cmd.getId();
@@ -954,7 +954,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
             sc.setParameters("snapshotTypeNEQ", Snapshot.Type.TEMPLATE.ordinal());
         }
 
-        return _snapshotDao.search(sc, searchFilter);
+        Pair<List<SnapshotVO>, Integer> result = _snapshotDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Snapshot>, Integer>(result.first(), result.second());
     }
 
 


Mime
View raw message