incubator-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: CS-16412: fixed count for following commands:
Date Tue, 16 Oct 2012 01:20:23 GMT
Updated Branches:
  refs/heads/master f72434261 -> 3f5733cea


CS-16412: fixed count for following commands:

listVlanIpRanges
listOsCategories
listOsTypes
listSystemVms
listPhysicalNetworks
listCounters
listConditions
listAutoScalePolicies
listAutoScaleVmProfiles
listAutoScaleVmGroups
listConfigurations
listStoragePools
listClusters
listPods
listInstanceGroups
listSSHKeyPairs
listHypervisorCapabilities
listNetworkServiceProviders
listVpnCustomerGateways
listVpnGateways
listVpnConnections
listProjects
listProjectAccounts
listProjectInvitations
listTrafficTypes

Conflicts:

	api/src/com/cloud/api/commands/ListAutoScalePoliciesCmd.java
	api/src/com/cloud/api/commands/ListAutoScaleVmGroupsCmd.java
	api/src/com/cloud/api/commands/ListAutoScaleVmProfilesCmd.java
	api/src/com/cloud/api/commands/ListConditionsCmd.java
	api/src/com/cloud/api/commands/ListCountersCmd.java
	api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java
	api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java
	api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java
	api/src/com/cloud/network/as/AutoScaleService.java
	server/src/com/cloud/network/as/AutoScaleManagerImpl.java
	server/src/com/cloud/network/as/dao/CounterDao.java
	server/src/com/cloud/network/as/dao/CounterDaoImpl.java
	server/src/com/cloud/projects/ProjectManagerImpl.java
	server/src/com/cloud/server/ManagementServerImpl.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/3f5733ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/3f5733ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/3f5733ce

Branch: refs/heads/master
Commit: 3f5733cea741420381d5767fba84224388096525
Parents: f724342
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Oct 15 16:32:27 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Oct 15 18:16:59 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/ListCfgsByCmd.java  |    7 +-
 .../com/cloud/api/commands/ListClustersCmd.java    |    7 +-
 .../api/commands/ListGuestOsCategoriesCmd.java     |    7 +-
 api/src/com/cloud/api/commands/ListGuestOsCmd.java |    7 +-
 .../commands/ListHypervisorCapabilitiesCmd.java    |    8 +-
 .../commands/ListNetworkServiceProvidersCmd.java   |    8 +-
 .../api/commands/ListPhysicalNetworksCmd.java      |    8 +-
 api/src/com/cloud/api/commands/ListPodsByCmd.java  |    8 +-
 .../cloud/api/commands/ListProjectAccountsCmd.java |    8 +-
 .../api/commands/ListProjectInvitationsCmd.java    |    8 +-
 .../com/cloud/api/commands/ListProjectsCmd.java    |    7 +-
 .../com/cloud/api/commands/ListSSHKeyPairsCmd.java |    8 +-
 .../cloud/api/commands/ListStoragePoolsCmd.java    |    8 +-
 .../com/cloud/api/commands/ListSystemVMsCmd.java   |    7 +-
 .../cloud/api/commands/ListTrafficTypesCmd.java    |    7 +-
 .../com/cloud/api/commands/ListVMGroupsCmd.java    |    7 +-
 .../cloud/api/commands/ListVlanIpRangesCmd.java    |    7 +-
 .../cloud/api/commands/ListVpnConnectionsCmd.java  |   20 ++--
 .../api/commands/ListVpnCustomerGatewaysCmd.java   |   20 ++--
 .../com/cloud/api/commands/ListVpnGatewaysCmd.java |   22 +++---
 api/src/com/cloud/network/NetworkService.java      |    6 +-
 .../com/cloud/network/vpn/Site2SiteVpnService.java |    8 +-
 api/src/com/cloud/projects/ProjectService.java     |    7 +-
 api/src/com/cloud/server/ManagementService.java    |   22 +++---
 server/src/com/cloud/api/ApiDBUtils.java           |    2 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   16 ++--
 .../network/dao/PhysicalNetworkTrafficTypeDao.java |    4 +-
 .../dao/PhysicalNetworkTrafficTypeDaoImpl.java     |    5 +-
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |   22 ++---
 .../src/com/cloud/projects/ProjectManagerImpl.java |   25 +++--
 server/src/com/cloud/server/ManagementServer.java  |    2 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   68 +++++++++------
 .../com/cloud/network/MockNetworkManagerImpl.java  |    6 +-
 .../com/cloud/projects/MockProjectManagerImpl.java |    8 +-
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    6 +-
 .../com/cloud/vpc/MockSite2SiteVpnManagerImpl.java |    7 +-
 36 files changed, 227 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListCfgsByCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListCfgsByCmd.java b/api/src/com/cloud/api/commands/ListCfgsByCmd.java
index 8dc740f..6e07ca9 100644
--- a/api/src/com/cloud/api/commands/ListCfgsByCmd.java
+++ b/api/src/com/cloud/api/commands/ListCfgsByCmd.java
@@ -28,6 +28,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ConfigurationResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.configuration.Configuration;
+import com.cloud.utils.Pair;
 
 @Implementation(description = "Lists all configurations.", responseObject = ConfigurationResponse.class)
 public class ListCfgsByCmd extends BaseListCmd {
@@ -78,16 +79,16 @@ public class ListCfgsByCmd extends BaseListCmd {
 
     @Override
     public void execute() {
-        List<? extends Configuration> result = _mgr.searchForConfigurations(this);
+        Pair<List<? extends Configuration>, Integer> result = _mgr.searchForConfigurations(this);
         ListResponse<ConfigurationResponse> response = new ListResponse<ConfigurationResponse>();
         List<ConfigurationResponse> configResponses = new ArrayList<ConfigurationResponse>();
-        for (Configuration cfg : result) {
+        for (Configuration cfg : result.first()) {
             ConfigurationResponse cfgResponse = _responseGenerator.createConfigurationResponse(cfg);
             cfgResponse.setObjectName("configuration");
             configResponses.add(cfgResponse);
         }
 
-        response.setResponses(configResponses);
+        response.setResponses(configResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListClustersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListClustersCmd.java b/api/src/com/cloud/api/commands/ListClustersCmd.java
index e3e2e50..e571bf5 100755
--- a/api/src/com/cloud/api/commands/ListClustersCmd.java
+++ b/api/src/com/cloud/api/commands/ListClustersCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ClusterResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.org.Cluster;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists clusters.", responseObject=ClusterResponse.class)
 public class ListClustersCmd extends BaseListCmd {
@@ -127,16 +128,16 @@ public class ListClustersCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends Cluster> result = _mgr.searchForClusters(this);
+        Pair<List<? extends Cluster>, Integer> result = _mgr.searchForClusters(this);
         ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
         List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
-        for (Cluster cluster : result) {
+        for (Cluster cluster : result.first()) {
             ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster,showCapacities);
             clusterResponse.setObjectName("cluster");
             clusterResponses.add(clusterResponse);
         }
 
-        response.setResponses(clusterResponses);
+        response.setResponses(clusterResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListGuestOsCategoriesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListGuestOsCategoriesCmd.java b/api/src/com/cloud/api/commands/ListGuestOsCategoriesCmd.java
index 9974aca..79ce709 100644
--- a/api/src/com/cloud/api/commands/ListGuestOsCategoriesCmd.java
+++ b/api/src/com/cloud/api/commands/ListGuestOsCategoriesCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.GuestOSCategoryResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.storage.GuestOsCategory;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all supported OS categories for this cloud.", responseObject=GuestOSCategoryResponse.class)
 public class ListGuestOsCategoriesCmd extends BaseListCmd {
@@ -72,10 +73,10 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends GuestOsCategory> result = _mgr.listGuestOSCategoriesByCriteria(this);
+        Pair<List<? extends GuestOsCategory>, Integer> result = _mgr.listGuestOSCategoriesByCriteria(this);
         ListResponse<GuestOSCategoryResponse> response = new ListResponse<GuestOSCategoryResponse>();
         List<GuestOSCategoryResponse> osCatResponses = new ArrayList<GuestOSCategoryResponse>();
-        for (GuestOsCategory osCategory : result) {
+        for (GuestOsCategory osCategory : result.first()) {
             GuestOSCategoryResponse categoryResponse = new GuestOSCategoryResponse();
             categoryResponse.setId(osCategory.getId());
             categoryResponse.setName(osCategory.getName());
@@ -84,7 +85,7 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
             osCatResponses.add(categoryResponse);
         }
 
-        response.setResponses(osCatResponses);
+        response.setResponses(osCatResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListGuestOsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListGuestOsCmd.java b/api/src/com/cloud/api/commands/ListGuestOsCmd.java
index 396c441..61ec453 100644
--- a/api/src/com/cloud/api/commands/ListGuestOsCmd.java
+++ b/api/src/com/cloud/api/commands/ListGuestOsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.GuestOSResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.storage.GuestOS;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all supported OS types for this cloud.", responseObject=GuestOSResponse.class)
 public class ListGuestOsCmd extends BaseListCmd {
@@ -79,10 +80,10 @@ public class ListGuestOsCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends GuestOS> result = _mgr.listGuestOSByCriteria(this);
+        Pair<List<? extends GuestOS>, Integer> result = _mgr.listGuestOSByCriteria(this);
         ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
         List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
-        for (GuestOS guestOS : result) {
+        for (GuestOS guestOS : result.first()) {
             GuestOSResponse guestOSResponse = new GuestOSResponse();
             guestOSResponse.setDescription(guestOS.getDisplayName());
             guestOSResponse.setId(guestOS.getId());
@@ -92,7 +93,7 @@ public class ListGuestOsCmd extends BaseListCmd {
             osResponses.add(guestOSResponse);
         }
 
-        response.setResponses(osResponses);
+        response.setResponses(osResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListHypervisorCapabilitiesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListHypervisorCapabilitiesCmd.java b/api/src/com/cloud/api/commands/ListHypervisorCapabilitiesCmd.java
index 0cda15a..9afd3eb 100644
--- a/api/src/com/cloud/api/commands/ListHypervisorCapabilitiesCmd.java
+++ b/api/src/com/cloud/api/commands/ListHypervisorCapabilitiesCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.HypervisorCapabilitiesResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.hypervisor.HypervisorCapabilities;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all hypervisor capabilities.", responseObject=HypervisorCapabilitiesResponse.class, since="3.0.0")
 public class ListHypervisorCapabilitiesCmd extends BaseListCmd {
@@ -76,16 +77,17 @@ public class ListHypervisorCapabilitiesCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends HypervisorCapabilities> hpvCapabilities = _mgr.listHypervisorCapabilities(getId(), getHypervisor(), getKeyword(), this.getStartIndex(), this.getPageSizeVal());
+        Pair<List<? extends HypervisorCapabilities>, Integer> hpvCapabilities = _mgr.listHypervisorCapabilities(getId(),
+                getHypervisor(), getKeyword(), this.getStartIndex(), this.getPageSizeVal());
         ListResponse<HypervisorCapabilitiesResponse> response = new ListResponse<HypervisorCapabilitiesResponse>();
         List<HypervisorCapabilitiesResponse> hpvCapabilitiesResponses = new ArrayList<HypervisorCapabilitiesResponse>();
-        for (HypervisorCapabilities capability : hpvCapabilities) {
+        for (HypervisorCapabilities capability : hpvCapabilities.first()) {
             HypervisorCapabilitiesResponse hpvCapabilityResponse = _responseGenerator.createHypervisorCapabilitiesResponse(capability);
             hpvCapabilityResponse.setObjectName("hypervisorCapabilities");
             hpvCapabilitiesResponses.add(hpvCapabilityResponse);
         }
 
-        response.setResponses(hpvCapabilitiesResponses);
+        response.setResponses(hpvCapabilitiesResponses, hpvCapabilities.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java b/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
index c973b35..97bfd77 100644
--- a/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
+++ b/api/src/com/cloud/api/commands/ListNetworkServiceProvidersCmd.java
@@ -30,6 +30,7 @@ import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.ProviderResponse;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 
 @Implementation(description="Lists network serviceproviders for a given physical network.", responseObject=ProviderResponse.class, since="3.0.0")
@@ -86,15 +87,16 @@ public class ListNetworkServiceProvidersCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends PhysicalNetworkServiceProvider> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(), getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
+        Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(),
+                getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
         ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
         List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
-        for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders) {
+        for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders.first()) {
             ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
             serviceProvidersResponses.add(serviceProviderResponse);
         }
 
-        response.setResponses(serviceProvidersResponses);
+        response.setResponses(serviceProvidersResponses, serviceProviders.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java b/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
index e1ec427..ed2968f 100644
--- a/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
+++ b/api/src/com/cloud/api/commands/ListPhysicalNetworksCmd.java
@@ -32,6 +32,7 @@ import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.PhysicalNetworkResponse;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists physical networks", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
 public class ListPhysicalNetworksCmd extends BaseListCmd {
@@ -86,15 +87,16 @@ public class ListPhysicalNetworksCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends PhysicalNetwork> result = _networkService.searchPhysicalNetworks(getId(),getZoneId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
+        Pair<List<? extends PhysicalNetwork>, Integer> result = _networkService.searchPhysicalNetworks(getId(),getZoneId(),
+                this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
         if (result != null) {
             ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
             List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
-            for (PhysicalNetwork network : result) {
+            for (PhysicalNetwork network : result.first()) {
                 PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
                 networkResponses.add(networkResponse);
             }
-            response.setResponses(networkResponses);
+            response.setResponses(networkResponses, result.second());
             response.setResponseName(getCommandName());
             this.setResponseObject(response);
         }else {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListPodsByCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListPodsByCmd.java b/api/src/com/cloud/api/commands/ListPodsByCmd.java
index b1270bb..37b8e29 100755
--- a/api/src/com/cloud/api/commands/ListPodsByCmd.java
+++ b/api/src/com/cloud/api/commands/ListPodsByCmd.java
@@ -26,10 +26,10 @@ import com.cloud.api.BaseListCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
-import com.cloud.api.BaseCmd.CommandType;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.PodResponse;
 import com.cloud.dc.Pod;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all Pods.", responseObject=PodResponse.class)
 public class ListPodsByCmd extends BaseListCmd {
@@ -93,16 +93,16 @@ public class ListPodsByCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends Pod> result = _mgr.searchForPods(this);
+        Pair<List<? extends Pod>, Integer> result = _mgr.searchForPods(this);
         ListResponse<PodResponse> response = new ListResponse<PodResponse>();
         List<PodResponse> podResponses = new ArrayList<PodResponse>();
-        for (Pod pod : result) {
+        for (Pod pod : result.first()) {
             PodResponse podResponse = _responseGenerator.createPodResponse(pod, showCapacities);
             podResponse.setObjectName("pod");
             podResponses.add(podResponse);
         }
 
-        response.setResponses(podResponses);
+        response.setResponses(podResponses, result.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListProjectAccountsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListProjectAccountsCmd.java b/api/src/com/cloud/api/commands/ListProjectAccountsCmd.java
index 893e753..0883633 100644
--- a/api/src/com/cloud/api/commands/ListProjectAccountsCmd.java
+++ b/api/src/com/cloud/api/commands/ListProjectAccountsCmd.java
@@ -31,6 +31,7 @@ import com.cloud.api.response.ProjectAccountResponse;
 import com.cloud.api.response.ProjectResponse;
 import com.cloud.projects.ProjectAccount;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists project's accounts", responseObject=ProjectResponse.class, since="3.0.0")
 public class ListProjectAccountsCmd extends BaseListCmd {
@@ -78,14 +79,15 @@ public class ListProjectAccountsCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends ProjectAccount> projectAccounts = _projectService.listProjectAccounts(projectId, accountName, role, this.getStartIndex(), this.getPageSizeVal());
+        Pair<List<? extends ProjectAccount>, Integer> projectAccounts = _projectService.listProjectAccounts(projectId,
+                accountName, role, this.getStartIndex(), this.getPageSizeVal());
         ListResponse<ProjectAccountResponse> response = new ListResponse<ProjectAccountResponse>();
         List<ProjectAccountResponse> projectResponses = new ArrayList<ProjectAccountResponse>();
-        for (ProjectAccount projectAccount : projectAccounts) {
+        for (ProjectAccount projectAccount : projectAccounts.first()) {
             ProjectAccountResponse projectAccountResponse = _responseGenerator.createProjectAccountResponse(projectAccount);
             projectResponses.add(projectAccountResponse);
         }
-        response.setResponses(projectResponses);
+        response.setResponses(projectResponses, projectAccounts.second());
         response.setResponseName(getCommandName());
         
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListProjectInvitationsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListProjectInvitationsCmd.java b/api/src/com/cloud/api/commands/ListProjectInvitationsCmd.java
index cb70780..fe69780 100644
--- a/api/src/com/cloud/api/commands/ListProjectInvitationsCmd.java
+++ b/api/src/com/cloud/api/commands/ListProjectInvitationsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.ProjectInvitationResponse;
 import com.cloud.projects.ProjectInvitation;
+import com.cloud.utils.Pair;
 
 @Implementation(description = "Lists projects and provides detailed information for listed projects", responseObject = ProjectInvitationResponse.class, since = "3.0.0")
 public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd {
@@ -82,15 +83,16 @@ public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd {
 
     @Override
     public void execute() {
-        List<? extends ProjectInvitation> invites = _projectService.listProjectInvitations(id, projectId, this.getAccountName(), this.getDomainId(), state, activeOnly, this.getStartIndex(), this.getPageSizeVal(),
+        Pair<List<? extends ProjectInvitation>, Integer> invites = _projectService.listProjectInvitations(id, projectId,
+                this.getAccountName(), this.getDomainId(), state, activeOnly, this.getStartIndex(), this.getPageSizeVal(),
                 this.isRecursive(), this.listAll());
         ListResponse<ProjectInvitationResponse> response = new ListResponse<ProjectInvitationResponse>();
         List<ProjectInvitationResponse> projectInvitationResponses = new ArrayList<ProjectInvitationResponse>();
-        for (ProjectInvitation invite : invites) {
+        for (ProjectInvitation invite : invites.first()) {
             ProjectInvitationResponse projectResponse = _responseGenerator.createProjectInvitationResponse(invite);
             projectInvitationResponses.add(projectResponse);
         }
-        response.setResponses(projectInvitationResponses);
+        response.setResponses(projectInvitationResponses, invites.second());
         response.setResponseName(getCommandName());
 
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListProjectsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListProjectsCmd.java b/api/src/com/cloud/api/commands/ListProjectsCmd.java
index 187e52c..b7a04eb 100644
--- a/api/src/com/cloud/api/commands/ListProjectsCmd.java
+++ b/api/src/com/cloud/api/commands/ListProjectsCmd.java
@@ -34,6 +34,7 @@ import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.ProjectResponse;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.projects.Project;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists projects and provides detailed information for listed projects", responseObject=ProjectResponse.class, since="3.0.0")
 public class ListProjectsCmd extends BaseListAccountResourcesCmd {
@@ -106,16 +107,16 @@ public class ListProjectsCmd extends BaseListAccountResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends Project> projects = _projectService.listProjects(id, name, displayText, state, 
+        Pair<List<? extends Project>, Integer> projects = _projectService.listProjects(id, name, displayText, state, 
                 this.getAccountName(), this.getDomainId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(),
                 this.listAll(), this.isRecursive(), getTags());
         ListResponse<ProjectResponse> response = new ListResponse<ProjectResponse>();
         List<ProjectResponse> projectResponses = new ArrayList<ProjectResponse>();
-        for (Project project : projects) {
+        for (Project project : projects.first()) {
             ProjectResponse projectResponse = _responseGenerator.createProjectResponse(project);
             projectResponses.add(projectResponse);
         }
-        response.setResponses(projectResponses);
+        response.setResponses(projectResponses, projects.second());
         response.setResponseName(getCommandName());
         
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java b/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java
index 3067554..8a6cb27 100644
--- a/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java
+++ b/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java
@@ -22,13 +22,13 @@ 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.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.SSHKeyPairResponse;
 import com.cloud.user.SSHKeyPair;
+import com.cloud.utils.Pair;
 
 @Implementation(description="List registered keypairs", responseObject=SSHKeyPairResponse.class) 
 public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -66,16 +66,16 @@ public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd {
     
 	@Override
 	public void execute() {
-		List<? extends SSHKeyPair> resultList = _mgr.listSSHKeyPairs(this);
+	    Pair<List<? extends SSHKeyPair>, Integer> resultList = _mgr.listSSHKeyPairs(this);
 		List<SSHKeyPairResponse> responses = new ArrayList<SSHKeyPairResponse>();
-		for (SSHKeyPair result : resultList) {
+		for (SSHKeyPair result : resultList.first()) {
 			SSHKeyPairResponse r = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
 			r.setObjectName("sshkeypair");
 			responses.add(r);
 		}
 		
         ListResponse<SSHKeyPairResponse> response = new ListResponse<SSHKeyPairResponse>();
-        response.setResponses(responses);
+        response.setResponses(responses, resultList.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListStoragePoolsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListStoragePoolsCmd.java b/api/src/com/cloud/api/commands/ListStoragePoolsCmd.java
index 6208dcd..7199b0b 100644
--- a/api/src/com/cloud/api/commands/ListStoragePoolsCmd.java
+++ b/api/src/com/cloud/api/commands/ListStoragePoolsCmd.java
@@ -26,11 +26,11 @@ import com.cloud.api.BaseListCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
-import com.cloud.api.BaseCmd.CommandType;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.StoragePoolResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.storage.StoragePool;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists storage pools.", responseObject=StoragePoolResponse.class)
 public class ListStoragePoolsCmd extends BaseListCmd {
@@ -114,16 +114,16 @@ public class ListStoragePoolsCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends StoragePool> pools = _mgr.searchForStoragePools(this);
+        Pair<List<? extends StoragePool>, Integer> pools = _mgr.searchForStoragePools(this);
         ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
         List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
-        for (StoragePool pool : pools) {
+        for (StoragePool pool : pools.first()) {
             StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolResponse(pool);
             poolResponse.setObjectName("storagepool");
             poolResponses.add(poolResponse);
         }
 
-        response.setResponses(poolResponses);
+        response.setResponses(poolResponses, pools.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListSystemVMsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListSystemVMsCmd.java b/api/src/com/cloud/api/commands/ListSystemVMsCmd.java
index 03e1985..4439197 100644
--- a/api/src/com/cloud/api/commands/ListSystemVMsCmd.java
+++ b/api/src/com/cloud/api/commands/ListSystemVMsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.SystemVmResponse;
 import com.cloud.async.AsyncJob;
+import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine;
 
 @Implementation(description="List system virtual machines.", responseObject=SystemVmResponse.class)
@@ -121,16 +122,16 @@ public class ListSystemVMsCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends VirtualMachine> systemVMs = _mgr.searchForSystemVm(this);
+        Pair<List<? extends VirtualMachine>, Integer> systemVMs = _mgr.searchForSystemVm(this);
         ListResponse<SystemVmResponse> response = new ListResponse<SystemVmResponse>();
         List<SystemVmResponse> vmResponses = new ArrayList<SystemVmResponse>();
-        for (VirtualMachine systemVM : systemVMs) {
+        for (VirtualMachine systemVM : systemVMs.first()) {
             SystemVmResponse vmResponse = _responseGenerator.createSystemVmResponse(systemVM);
             vmResponse.setObjectName("systemvm");
             vmResponses.add(vmResponse);
         }
 
-        response.setResponses(vmResponses);
+        response.setResponses(vmResponses, systemVMs.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java b/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
index 59ad2a7..671d406 100755
--- a/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
+++ b/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
@@ -31,6 +31,7 @@ import com.cloud.api.response.ProviderResponse;
 import com.cloud.api.response.TrafficTypeResponse;
 import com.cloud.network.PhysicalNetworkTrafficType;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 
 @Implementation(description="Lists traffic types of a given physical network.", responseObject=ProviderResponse.class, since="3.0.0")
@@ -72,15 +73,15 @@ public class ListTrafficTypesCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends PhysicalNetworkTrafficType> trafficTypes = _networkService.listTrafficTypes(getPhysicalNetworkId());
+        Pair<List<? extends PhysicalNetworkTrafficType>, Integer> trafficTypes = _networkService.listTrafficTypes(getPhysicalNetworkId());
         ListResponse<TrafficTypeResponse> response = new ListResponse<TrafficTypeResponse>();
         List<TrafficTypeResponse> trafficTypesResponses = new ArrayList<TrafficTypeResponse>();
-        for (PhysicalNetworkTrafficType trafficType : trafficTypes) {
+        for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
             TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
             trafficTypesResponses.add(trafficTypeResponse);
         }
 
-        response.setResponses(trafficTypesResponses);
+        response.setResponses(trafficTypesResponses, trafficTypes.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListVMGroupsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVMGroupsCmd.java b/api/src/com/cloud/api/commands/ListVMGroupsCmd.java
index 33cc927..34a5e19 100644
--- a/api/src/com/cloud/api/commands/ListVMGroupsCmd.java
+++ b/api/src/com/cloud/api/commands/ListVMGroupsCmd.java
@@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.response.InstanceGroupResponse;
 import com.cloud.api.response.ListResponse;
+import com.cloud.utils.Pair;
 import com.cloud.vm.InstanceGroup;
 
 @Implementation(description="Lists vm groups", responseObject=InstanceGroupResponse.class)
@@ -70,16 +71,16 @@ public class ListVMGroupsCmd extends BaseListProjectAndAccountResourcesCmd {
 
     @Override
     public void execute(){
-        List<? extends InstanceGroup> groups = _mgr.searchForVmGroups(this);
+        Pair<List<? extends InstanceGroup>, Integer> groups = _mgr.searchForVmGroups(this);
         ListResponse<InstanceGroupResponse> response = new ListResponse<InstanceGroupResponse>();
         List<InstanceGroupResponse> responses = new ArrayList<InstanceGroupResponse>();
-        for (InstanceGroup group : groups) {
+        for (InstanceGroup group : groups.first()) {
             InstanceGroupResponse groupResponse = _responseGenerator.createInstanceGroupResponse(group);
             groupResponse.setObjectName("instancegroup");
             responses.add(groupResponse);
         }
 
-        response.setResponses(responses);
+        response.setResponses(responses, groups.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java b/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java
index 039628a..5cefa65 100644
--- a/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java
+++ b/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.VlanIpRangeResponse;
 import com.cloud.dc.Vlan;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists all VLAN IP ranges.", responseObject=VlanIpRangeResponse.class)
 public class ListVlanIpRangesCmd extends BaseListCmd {
@@ -132,16 +133,16 @@ public class ListVlanIpRangesCmd extends BaseListCmd {
     
     @Override
     public void execute(){
-        List<? extends Vlan> vlans = _mgr.searchForVlans(this);
+        Pair<List<? extends Vlan>, Integer> vlans = _mgr.searchForVlans(this);
         ListResponse<VlanIpRangeResponse> response = new ListResponse<VlanIpRangeResponse>();
         List<VlanIpRangeResponse> vlanResponses = new ArrayList<VlanIpRangeResponse>();
-        for (Vlan vlan : vlans) {  
+        for (Vlan vlan : vlans.first()) {  
             VlanIpRangeResponse vlanResponse = _responseGenerator.createVlanIpRangeResponse(vlan);
             vlanResponse.setObjectName("vlaniprange");
             vlanResponses.add(vlanResponse);
         }
 
-        response.setResponses(vlanResponses);
+        response.setResponses(vlanResponses, vlans.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java b/api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java
index 512f945..c7d5523 100644
--- a/api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java
+++ b/api/src/com/cloud/api/commands/ListVpnConnectionsCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.Site2SiteVpnConnectionResponse;
 import com.cloud.network.Site2SiteVpnConnection;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists site to site vpn connection gateways", responseObject=Site2SiteVpnConnectionResponse.class)
 public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -72,20 +73,19 @@ public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd
 
     @Override
     public void execute(){
-        List<Site2SiteVpnConnection> conns = _s2sVpnService.searchForVpnConnections(this);
+        Pair<List<? extends Site2SiteVpnConnection>, Integer> conns = _s2sVpnService.searchForVpnConnections(this);
         ListResponse<Site2SiteVpnConnectionResponse> response = new ListResponse<Site2SiteVpnConnectionResponse>();
         List<Site2SiteVpnConnectionResponse> connResponses = new ArrayList<Site2SiteVpnConnectionResponse>();
-        if (conns != null && !conns.isEmpty()) {
-        	for (Site2SiteVpnConnection conn : conns) {
-                if (conn == null) {
-                    continue;
-                }
-            	Site2SiteVpnConnectionResponse site2SiteVpnConnectonRes = _responseGenerator.createSite2SiteVpnConnectionResponse(conn);
-            	site2SiteVpnConnectonRes.setObjectName("vpnconnection");
-                connResponses.add(site2SiteVpnConnectonRes);
+        for (Site2SiteVpnConnection conn : conns.first()) {
+            if (conn == null) {
+                continue;
             }
+        	Site2SiteVpnConnectionResponse site2SiteVpnConnectonRes = _responseGenerator.createSite2SiteVpnConnectionResponse(conn);
+        	site2SiteVpnConnectonRes.setObjectName("vpnconnection");
+            connResponses.add(site2SiteVpnConnectonRes);
         }
-        response.setResponses(connResponses);
+        
+        response.setResponses(connResponses, conns.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java b/api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java
index 1e8b06b..51fde93 100644
--- a/api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java
+++ b/api/src/com/cloud/api/commands/ListVpnCustomerGatewaysCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
 import com.cloud.network.Site2SiteCustomerGateway;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists site to site vpn customer gateways", responseObject=Site2SiteCustomerGatewayResponse.class)
 public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -64,20 +65,19 @@ public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourc
 
     @Override
     public void execute(){
-        List<Site2SiteCustomerGateway> gws = _s2sVpnService.searchForCustomerGateways(this);
+        Pair<List<? extends Site2SiteCustomerGateway>, Integer> gws = _s2sVpnService.searchForCustomerGateways(this);
         ListResponse<Site2SiteCustomerGatewayResponse> response = new ListResponse<Site2SiteCustomerGatewayResponse>();
         List<Site2SiteCustomerGatewayResponse> gwResponses = new ArrayList<Site2SiteCustomerGatewayResponse>();
-        if (gws != null && !gws.isEmpty()) {
-        	for (Site2SiteCustomerGateway gw : gws) {
-                if (gw == null) {
-                    continue;
-                }
-            	Site2SiteCustomerGatewayResponse site2SiteCustomerGatewayRes = _responseGenerator.createSite2SiteCustomerGatewayResponse(gw);
-            	site2SiteCustomerGatewayRes.setObjectName("vpncustomergateway");
-                gwResponses.add(site2SiteCustomerGatewayRes);
+        for (Site2SiteCustomerGateway gw : gws.first()) {
+            if (gw == null) {
+                continue;
             }
+        	Site2SiteCustomerGatewayResponse site2SiteCustomerGatewayRes = _responseGenerator.createSite2SiteCustomerGatewayResponse(gw);
+        	site2SiteCustomerGatewayRes.setObjectName("vpncustomergateway");
+            gwResponses.add(site2SiteCustomerGatewayRes);
         }
-        response.setResponses(gwResponses);
+        
+        response.setResponses(gwResponses, gws.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java b/api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java
index 63b212b..ec0c054 100644
--- a/api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java
+++ b/api/src/com/cloud/api/commands/ListVpnGatewaysCmd.java
@@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.Site2SiteVpnGatewayResponse;
 import com.cloud.network.Site2SiteVpnGateway;
+import com.cloud.utils.Pair;
 
 @Implementation(description="Lists site 2 site vpn gateways", responseObject=Site2SiteVpnGatewayResponse.class)
 public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -71,20 +72,19 @@ public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
 
     @Override
     public void execute(){
-        List<Site2SiteVpnGateway> gws = _s2sVpnService.searchForVpnGateways(this);
+        Pair<List<? extends Site2SiteVpnGateway>, Integer> gws = _s2sVpnService.searchForVpnGateways(this);
         ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<Site2SiteVpnGatewayResponse>();
         List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<Site2SiteVpnGatewayResponse>();
-        if (gws != null && !gws.isEmpty()) {
-        	 for (Site2SiteVpnGateway gw : gws) {
-                 if (gw == null) {
-                     continue;
-                 }
-             	Site2SiteVpnGatewayResponse site2SiteVpnGatewayRes = _responseGenerator.createSite2SiteVpnGatewayResponse(gw);
-             	site2SiteVpnGatewayRes.setObjectName("vpngateway");
-                 gwResponses.add(site2SiteVpnGatewayRes);
-             }
+        for (Site2SiteVpnGateway gw : gws.first()) {
+            if (gw == null) {
+                continue;
+            }
+        	Site2SiteVpnGatewayResponse site2SiteVpnGatewayRes = _responseGenerator.createSite2SiteVpnGatewayResponse(gw);
+        	site2SiteVpnGatewayRes.setObjectName("vpngateway");
+            gwResponses.add(site2SiteVpnGatewayRes);
         }
-        response.setResponses(gwResponses);
+        
+        response.setResponses(gwResponses, gws.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 6bbc36c..a200561 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -82,7 +82,7 @@ public interface NetworkService {
     PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, 
             List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
 
-    List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, 
+    Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword, 
             Long startIndex, Long pageSize, String name);
 
     PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, 
@@ -97,7 +97,7 @@ public interface NetworkService {
     PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
             Long destinationPhysicalNetworkId, List<String> enabledServices);
 
-    List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name,
+    Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> listNetworkServiceProviders(Long physicalNetworkId, String name,
             String state, Long startIndex, Long pageSize);
 
     PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, List<String> enabledServices);
@@ -123,7 +123,7 @@ public interface NetworkService {
 
     boolean deletePhysicalNetworkTrafficType(Long id);
 
-    List<? extends PhysicalNetworkTrafficType> listTrafficTypes(Long physicalNetworkId);
+    Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
 
     PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/network/vpn/Site2SiteVpnService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpn/Site2SiteVpnService.java b/api/src/com/cloud/network/vpn/Site2SiteVpnService.java
index 0e98b9e..69eab1a 100644
--- a/api/src/com/cloud/network/vpn/Site2SiteVpnService.java
+++ b/api/src/com/cloud/network/vpn/Site2SiteVpnService.java
@@ -31,10 +31,10 @@ import com.cloud.api.commands.ResetVpnConnectionCmd;
 import com.cloud.api.commands.UpdateVpnCustomerGatewayCmd;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
 import com.cloud.network.Site2SiteCustomerGateway;
 import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.Site2SiteVpnGateway;
+import com.cloud.utils.Pair;
 
 public interface Site2SiteVpnService {
     Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd);
@@ -46,8 +46,8 @@ public interface Site2SiteVpnService {
     boolean deleteVpnGateway(DeleteVpnGatewayCmd deleteVpnGatewayCmd);
     boolean deleteVpnConnection(DeleteVpnConnectionCmd deleteVpnConnectionCmd) throws ResourceUnavailableException;
     Site2SiteVpnConnection resetVpnConnection(ResetVpnConnectionCmd resetVpnConnectionCmd) throws ResourceUnavailableException;
-    List<Site2SiteCustomerGateway> searchForCustomerGateways(ListVpnCustomerGatewaysCmd listVpnCustomerGatewaysCmd);
-    List<Site2SiteVpnGateway> searchForVpnGateways(ListVpnGatewaysCmd listVpnGatewaysCmd);
-    List<Site2SiteVpnConnection> searchForVpnConnections(ListVpnConnectionsCmd listVpnConnectionsCmd);
+    Pair<List<? extends Site2SiteCustomerGateway>, Integer> searchForCustomerGateways(ListVpnCustomerGatewaysCmd listVpnCustomerGatewaysCmd);
+    Pair<List<? extends Site2SiteVpnGateway>, Integer> searchForVpnGateways(ListVpnGatewaysCmd listVpnGatewaysCmd);
+    Pair<List<? extends Site2SiteVpnConnection>, Integer> searchForVpnConnections(ListVpnConnectionsCmd listVpnConnectionsCmd);
     Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd updateVpnCustomerGatewayCmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/api/src/com/cloud/projects/ProjectService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/projects/ProjectService.java b/api/src/com/cloud/projects/ProjectService.java
index 5834f1c..ea143b7 100644
--- a/api/src/com/cloud/projects/ProjectService.java
+++ b/api/src/com/cloud/projects/ProjectService.java
@@ -24,6 +24,7 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.projects.ProjectAccount.Role;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 
 public interface ProjectService {
     /**
@@ -60,7 +61,7 @@ public interface ProjectService {
      */
     Project getProject(long id);
 
-    List<? extends Project> listProjects(Long id, String name, String displayText, String state, String accountName, 
+    Pair<List<? extends Project>, Integer> listProjects(Long id, String name, String displayText, String state, String accountName, 
             Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll, boolean isRecursive, Map<String, String> tags);
 
     ProjectAccount assignAccountToProject(Project project, long accountId, Role accountRole);
@@ -79,9 +80,9 @@ public interface ProjectService {
 
     boolean deleteAccountFromProject(long projectId, String accountName);
 
-    List<? extends ProjectAccount> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal);
+    Pair<List<? extends ProjectAccount>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal);
 
-    List<? extends ProjectInvitation> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
+    Pair<List<? extends ProjectInvitation>, Integer> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
             boolean listAll);
 
     boolean updateInvitation(long projectId, String accountName, String token, boolean accept);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/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 d1a789e..7532cae 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -114,7 +114,7 @@ public interface ManagementService {
      * 
      * @return map of configuration name/values
      */
-    List<? extends Configuration> searchForConfigurations(ListCfgsByCmd c);
+    Pair<List<? extends Configuration>, Integer> searchForConfigurations(ListCfgsByCmd c);
 
     /**
      * Searches for Service Offerings by the specified search criteria Can search by: "name"
@@ -130,7 +130,7 @@ public interface ManagementService {
      * @param c
      * @return
      */
-    List<? extends Cluster> searchForClusters(ListClustersCmd c);
+    Pair<List<? extends Cluster>, Integer> searchForClusters(ListClustersCmd c);
     
     /**
      * Searches for Clusters by the specified zone Id.
@@ -145,7 +145,7 @@ public interface ManagementService {
      * @param cmd
      * @return List of Pods
      */
-    List<? extends Pod> searchForPods(ListPodsByCmd cmd);
+    Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd);
 
     /**
      * Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
@@ -201,14 +201,14 @@ public interface ManagementService {
      * 
      * @return list of GuestOS
      */
-    List<? extends GuestOS> listGuestOSByCriteria(ListGuestOsCmd cmd);
+    Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(ListGuestOsCmd cmd);
 
     /**
      * Obtains a list of all guest OS categories.
      * 
      * @return list of GuestOSCategories
      */
-    List<? extends GuestOsCategory> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd);
+    Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd);
 
     VirtualMachine stopSystemVM(StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
 
@@ -283,7 +283,7 @@ public interface ManagementService {
      *            the command that wraps the search criteria (zone, pod, name, IP address, path, and cluster id)
      * @return a list of storage pools that match the given criteria
      */
-    List<? extends StoragePool> searchForStoragePools(ListStoragePoolsCmd cmd);
+    Pair<List<? extends StoragePool>, Integer> searchForStoragePools(ListStoragePoolsCmd cmd);
 
     /**
      * List system VMs by the given search criteria
@@ -292,7 +292,7 @@ public interface ManagementService {
      *            the command that wraps the search criteria (host, name, state, type, zone, pod, and/or id)
      * @return the list of system vms that match the given criteria
      */
-    List<? extends VirtualMachine> searchForSystemVm(ListSystemVMsCmd cmd);
+    Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd);
 
     /**
      * Returns back a SHA1 signed response
@@ -307,7 +307,7 @@ public interface ManagementService {
 
     InstanceGroup updateVmGroup(UpdateVMGroupCmd cmd);
 
-    List<? extends InstanceGroup> searchForVmGroups(ListVMGroupsCmd cmd);
+    Pair<List<? extends InstanceGroup>, Integer> searchForVmGroups(ListVMGroupsCmd cmd);
 
     Map<String, Object> listCapabilities(ListCapabilitiesCmd cmd);
 
@@ -354,7 +354,7 @@ public interface ManagementService {
      * @param cmd
      * @return List of Vlans
      */
-    List<? extends Vlan> searchForVlans(ListVlanIpRangesCmd cmd);
+    Pair<List<? extends Vlan>, Integer> searchForVlans(ListVlanIpRangesCmd cmd);
 
     /**
      * Search for async jobs by account and/or startDate
@@ -383,7 +383,7 @@ public interface ManagementService {
      *            The api command class.
      * @return The list of key pairs found.
      */
-    List<? extends SSHKeyPair> listSSHKeyPairs(ListSSHKeyPairsCmd cmd);
+    Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(ListSSHKeyPairsCmd cmd);
 
     /**
      * Registers a key pair for a given public key.
@@ -439,7 +439,7 @@ public interface ManagementService {
 
     String[] listEventTypes();
 
-    List<? extends HypervisorCapabilities> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, String keyword, Long startIndex, Long pageSizeVal);
+    Pair<List<? extends HypervisorCapabilities>, Integer> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, String keyword, Long startIndex, Long pageSizeVal);
 
     HypervisorCapabilities updateHypervisorCapabilities(Long id, Long maxGuestsLimit, Boolean securityGroupEnabled);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/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 1d6ba4f..418fe362 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -327,7 +327,7 @@ public class ApiDBUtils {
     }
 
     public static List<? extends StoragePoolVO> searchForStoragePools(Criteria c) {
-        return _ms.searchForStoragePools(c);
+        return _ms.searchForStoragePools(c).first();
     }
 
     // ///////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 13a2bb1..cf5b6e3 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -5250,7 +5250,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
     }
 
     @Override
-    public List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name) {
+    public Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name) {
         Filter searchFilter = new Filter(PhysicalNetworkVO.class, "id", Boolean.TRUE, startIndex, pageSize);
         SearchCriteria<PhysicalNetworkVO> sc = _physicalNetworkDao.createSearchCriteria();
 
@@ -5266,7 +5266,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
             sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
         }
 
-        return _physicalNetworkDao.search(sc, searchFilter);
+        Pair<List<PhysicalNetworkVO>, Integer> result =  _physicalNetworkDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends PhysicalNetwork>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -5716,7 +5717,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
     }
 
     @Override
-    public List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name, String state, Long startIndex, Long pageSize) {
+    public Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> listNetworkServiceProviders(Long physicalNetworkId,
+            String name, String state, Long startIndex, Long pageSize) {
 
         Filter searchFilter = new Filter(PhysicalNetworkServiceProviderVO.class, "id", false, startIndex, pageSize);
         SearchBuilder<PhysicalNetworkServiceProviderVO> sb = _pNSPDao.createSearchBuilder();
@@ -5734,7 +5736,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
             sc.addAnd("state", Op.EQ, state);
         }
 
-        return _pNSPDao.search(sc, searchFilter);
+        Pair<List<PhysicalNetworkServiceProviderVO>, Integer> result =  _pNSPDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends PhysicalNetworkServiceProvider>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -6328,7 +6331,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
     }
 
     @Override
-    public List<? extends PhysicalNetworkTrafficType> listTrafficTypes(Long physicalNetworkId) {
+    public Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId) {
         PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
         if (network == null) {
             InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system");
@@ -6336,7 +6339,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
             throw ex;
         }
 
-        return _pNTrafficTypeDao.listBy(physicalNetworkId);
+        Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> result = _pNTrafficTypeDao.listAndCountBy(physicalNetworkId);
+        return new Pair<List<? extends PhysicalNetworkTrafficType>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
index 2efd904..42e5b4e 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
@@ -16,14 +16,16 @@
 // under the License.
 package com.cloud.network.dao;
 
+
 import java.util.List;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.utils.Pair;
 import com.cloud.utils.db.GenericDao;
 
 public interface PhysicalNetworkTrafficTypeDao extends GenericDao<PhysicalNetworkTrafficTypeVO, Long> {
-    List<PhysicalNetworkTrafficTypeVO> listBy(long physicalNetworkId);
+    Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> listAndCountBy(long physicalNetworkId);
     boolean isTrafficTypeSupported(long physicalNetworkId, TrafficType trafficType);
     String getNetworkTag (long physicalNetworkId, TrafficType trafficType, HypervisorType hType);
     PhysicalNetworkTrafficTypeVO findBy(long physicalNetworkId, TrafficType trafficType);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
index c89477d..5a44cd5 100755
--- a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
@@ -22,6 +22,7 @@ import javax.ejb.Local;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.utils.Pair;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.GenericSearchBuilder;
@@ -77,10 +78,10 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
     }
 
     @Override
-    public List<PhysicalNetworkTrafficTypeVO> listBy(long physicalNetworkId) {
+    public Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> listAndCountBy(long physicalNetworkId) {
         SearchCriteria<PhysicalNetworkTrafficTypeVO> sc = physicalNetworkSearch.create();
         sc.setParameters("physicalNetworkId", physicalNetworkId);
-        return search(sc, null);
+        return searchAndCount(sc, null);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index ae0f4ec..da993d0 100644
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@ -67,6 +67,7 @@ import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserStatisticsDao;
 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;
@@ -568,7 +569,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
     }
 
     @Override
-    public List<Site2SiteCustomerGateway> searchForCustomerGateways(ListVpnCustomerGatewaysCmd cmd) {
+    public Pair<List<? extends Site2SiteCustomerGateway>, Integer> searchForCustomerGateways(ListVpnCustomerGatewaysCmd cmd) {
         Long id = cmd.getId();
         Long domainId = cmd.getDomainId();
         boolean isRecursive = cmd.isRecursive();
@@ -600,13 +601,12 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
             sc.addAnd("id", SearchCriteria.Op.EQ, id);
         }
 
-        List<Site2SiteCustomerGateway> results = new ArrayList<Site2SiteCustomerGateway>();
-        results.addAll(_customerGatewayDao.search(sc, searchFilter));
-        return results;
+        Pair<List<Site2SiteCustomerGatewayVO>, Integer> result = _customerGatewayDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Site2SiteCustomerGateway>, Integer> (result.first(), result.second());
     }
 
     @Override
-    public List<Site2SiteVpnGateway> searchForVpnGateways(ListVpnGatewaysCmd cmd) {
+    public Pair<List<? extends Site2SiteVpnGateway>, Integer> searchForVpnGateways(ListVpnGatewaysCmd cmd) {
         Long id = cmd.getId();
         Long vpcId = cmd.getVpcId();
         
@@ -645,13 +645,12 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
             sc.addAnd("vpcId", SearchCriteria.Op.EQ, vpcId);
         }
 
-        List<Site2SiteVpnGateway> results = new ArrayList<Site2SiteVpnGateway>();
-        results.addAll(_vpnGatewayDao.search(sc, searchFilter));
-        return results;
+        Pair<List<Site2SiteVpnGatewayVO>, Integer> result = _vpnGatewayDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Site2SiteVpnGateway>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<Site2SiteVpnConnection> searchForVpnConnections(ListVpnConnectionsCmd cmd) {
+    public Pair<List<? extends Site2SiteVpnConnection>, Integer> searchForVpnConnections(ListVpnConnectionsCmd cmd) {
         Long id = cmd.getId();
         Long vpcId = cmd.getVpcId();
 
@@ -695,9 +694,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
             sc.setJoinParameters("gwSearch", "vpcId", vpcId);
         }
 
-        List<Site2SiteVpnConnection> results = new ArrayList<Site2SiteVpnConnection>();
-        results.addAll(_vpnConnectionDao.search(sc, searchFilter));
-        return results;
+        Pair<List<Site2SiteVpnConnectionVO>, Integer> result = _vpnConnectionDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Site2SiteVpnConnection>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/projects/ProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java
index 77b778e..8cbd313 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -72,6 +72,7 @@ import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -352,7 +353,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
     }
     
     @Override
-    public List<? extends Project> listProjects(Long id, String name, String displayText, String state, 
+    public Pair<List<? extends Project>, Integer> listProjects(Long id, String name, String displayText, String state, 
             String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll, 
             boolean isRecursive, Map<String, String> tags) {
         Account caller = UserContext.current().getCaller();
@@ -468,8 +469,9 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
                 count++;
             }
         }
-        
-        return _projectDao.search(sc, searchFilter);
+
+        Pair<List<ProjectVO>, Integer> result = _projectDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Project>, Integer>(result.first(), result.second());
     }
     
     @Override
@@ -740,7 +742,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
     
     
     @Override
-    public List<? extends ProjectAccount> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal) {
+    public Pair<List<? extends ProjectAccount>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal) {
         Account caller = UserContext.current().getCaller();
         
         //check that the project exists
@@ -778,8 +780,9 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
         if (accountName != null) {
             sc.setJoinParameters("accountSearch", "accountName", accountName);
         }
-        
-        return _projectAccountDao.search(sc, searchFilter);
+
+        Pair<List<ProjectAccountVO>, Integer> result = _projectAccountDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends ProjectAccount>, Integer>(result.first(), result.second());
     }
     
     public ProjectInvitation createAccountInvitation(Project project, Long accountId) { 
@@ -851,8 +854,9 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
     }
     
     @Override
-    public List<? extends ProjectInvitation> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll) {
-    	Account caller = UserContext.current().getCaller();
+    public Pair<List<? extends ProjectInvitation>, Integer> listProjectInvitations(Long id, Long projectId,
+            String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll) {
+        Account caller = UserContext.current().getCaller();
         List<Long> permittedAccounts = new ArrayList<Long>();
         
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
@@ -890,8 +894,9 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
             sc.setParameters("state", ProjectInvitation.State.Pending);
             sc.setParameters("created", new Date((DateUtil.currentGMTTime().getTime()) - _invitationTimeOut));
         }
-        
-        return _projectInvitationDao.search(sc, searchFilter);
+
+        Pair<List<ProjectInvitationVO>, Integer> result = _projectInvitationDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends ProjectInvitation>, Integer>(result.first(), result.second());
     }
     
     @Override @DB

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/src/com/cloud/server/ManagementServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServer.java b/server/src/com/cloud/server/ManagementServer.java
index 941d30c..473b0ee 100755
--- a/server/src/com/cloud/server/ManagementServer.java
+++ b/server/src/com/cloud/server/ManagementServer.java
@@ -92,7 +92,7 @@ public interface ManagementServer extends ManagementService {
 
     public long getMemoryOrCpuCapacityByHost(Long hostId, short capacityType);
 
-    List<? extends StoragePoolVO> searchForStoragePools(Criteria c);
+    Pair<List<StoragePoolVO>, Integer> searchForStoragePools(Criteria c);
 
     String getHashKey();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/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 a698c93..a916eb6 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -111,6 +111,7 @@ import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
+import com.cloud.configuration.Configuration;
 import com.cloud.configuration.ConfigurationVO;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.consoleproxy.ConsoleProxyManagementState;
@@ -119,7 +120,9 @@ import com.cloud.dc.AccountVlanMapVO;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.HostPodVO;
+import com.cloud.dc.Pod;
 import com.cloud.dc.PodVlanMapVO;
+import com.cloud.dc.Vlan;
 import com.cloud.dc.Vlan.VlanType;
 import com.cloud.dc.VlanVO;
 import com.cloud.dc.dao.AccountVlanMapDao;
@@ -177,11 +180,14 @@ import com.cloud.server.ResourceTag.TaggedResourceType;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.GuestOS;
 import com.cloud.storage.GuestOSCategoryVO;
 import com.cloud.storage.GuestOSVO;
+import com.cloud.storage.GuestOsCategory;
 import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.StorageManager;
+import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.Upload;
 import com.cloud.storage.Upload.Mode;
@@ -237,6 +243,7 @@ import com.cloud.utils.net.NetUtils;
 import com.cloud.utils.ssh.SSHKeysHelper;
 import com.cloud.vm.ConsoleProxyVO;
 import com.cloud.vm.DomainRouterVO;
+import com.cloud.vm.InstanceGroup;
 import com.cloud.vm.InstanceGroupVO;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.SecondaryStorageVmVO;
@@ -822,7 +829,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
     
     @Override
-    public List<ClusterVO> searchForClusters(ListClustersCmd cmd) {
+    public Pair<List<? extends Cluster>, Integer> searchForClusters(ListClustersCmd cmd) {
         Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
 
@@ -872,7 +879,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("name", SearchCriteria.Op.SC, ssc);
         }
 
-        return _clusterDao.search(sc, searchFilter);
+        Pair<List<ClusterVO>, Integer> result = _clusterDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Cluster>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -1065,7 +1073,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<HostPodVO> searchForPods(ListPodsByCmd cmd) {
+    public Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd) {
         Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchCriteria<HostPodVO> sc = _hostPodDao.createSearchCriteria();
 
@@ -1101,11 +1109,12 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState);
         }
 
-        return _hostPodDao.search(sc, searchFilter);
+        Pair<List<HostPodVO>, Integer> result =  _hostPodDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Pod>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<VlanVO> searchForVlans(ListVlanIpRangesCmd cmd) {
+    public Pair<List<? extends Vlan>, Integer> searchForVlans(ListVlanIpRangesCmd cmd) {
         // If an account name and domain ID are specified, look up the account
         String accountName = cmd.getAccountName();
         Long domainId = cmd.getDomainId();
@@ -1219,11 +1228,12 @@ public class ManagementServerImpl implements ManagementServer {
             }
         }
 
-        return _vlanDao.search(sc, searchFilter);
+        Pair<List<VlanVO>, Integer> result = _vlanDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Vlan>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<ConfigurationVO> searchForConfigurations(ListCfgsByCmd cmd) {
+    public Pair<List<? extends Configuration>, Integer> searchForConfigurations(ListCfgsByCmd cmd) {
         Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
 
@@ -1254,7 +1264,8 @@ public class ManagementServerImpl implements ManagementServer {
         // hidden configurations are not displayed using the search API
         sc.addAnd("category", SearchCriteria.Op.NEQ, "Hidden");
 
-        return _configDao.search(sc, searchFilter);
+        Pair<List<ConfigurationVO>, Integer> result = _configDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends Configuration>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -1867,7 +1878,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<GuestOSVO> listGuestOSByCriteria(ListGuestOsCmd cmd) {
+    public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(ListGuestOsCmd cmd) {
         Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
         Long id = cmd.getId();
         Long osCategoryId = cmd.getOsCategoryId();
@@ -1892,11 +1903,12 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
         }
 
-        return _guestOSDao.search(sc, searchFilter);
+        Pair<List<GuestOSVO>, Integer> result = _guestOSDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends GuestOS>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<GuestOSCategoryVO> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd) {
+    public Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd) {
         Filter searchFilter = new Filter(GuestOSCategoryVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
         Long id = cmd.getId();
         String name = cmd.getName();
@@ -1916,7 +1928,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
         }
 
-        return _guestOSCategoryDao.search(sc, searchFilter);
+        Pair<List<GuestOSCategoryVO>, Integer> result = _guestOSCategoryDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends GuestOsCategory>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -2476,7 +2489,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<? extends StoragePoolVO> searchForStoragePools(ListStoragePoolsCmd cmd) {
+    public Pair<List<? extends StoragePool>, Integer> searchForStoragePools(ListStoragePoolsCmd cmd) {
 
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
         Criteria c = new Criteria("id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
@@ -2489,11 +2502,12 @@ public class ManagementServerImpl implements ManagementServer {
         c.addCriteria(Criteria.PODID, cmd.getPodId());
         c.addCriteria(Criteria.DATACENTERID, zoneId);
 
-        return searchForStoragePools(c);
+        Pair<List<StoragePoolVO>, Integer> result = searchForStoragePools(c);
+        return new Pair<List<? extends StoragePool>, Integer>(result.first(), result.second());
     }
 
     @Override
-    public List<? extends StoragePoolVO> searchForStoragePools(Criteria c) {
+    public Pair<List<StoragePoolVO>, Integer> searchForStoragePools(Criteria c) {
         Filter searchFilter = new Filter(StoragePoolVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
         SearchCriteria<StoragePoolVO> sc = _poolDao.createSearchCriteria();
 
@@ -2541,7 +2555,7 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("clusterId", SearchCriteria.Op.EQ, cluster);
         }
 
-        return _poolDao.search(sc, searchFilter);
+        return _poolDao.searchAndCount(sc, searchFilter);
     }
 
     @Override
@@ -2651,7 +2665,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<? extends VMInstanceVO> searchForSystemVm(ListSystemVMsCmd cmd) {
+    public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd) {
         String type = cmd.getSystemVmType();
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
         Long id = cmd.getId();
@@ -2720,7 +2734,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.setJoinParameters("volumeSearch", "poolId", storageId);
         }
 
-        return _vmInstanceDao.search(sc, searchFilter);
+        Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -3111,7 +3126,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<InstanceGroupVO> searchForVmGroups(ListVMGroupsCmd cmd) {
+    public Pair<List<? extends InstanceGroup>, Integer> searchForVmGroups(ListVMGroupsCmd cmd) {
         Long id = cmd.getId();
         String name = cmd.getGroupName();
         String keyword = cmd.getKeyword();
@@ -3178,7 +3193,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.setParameters("name", "%" + name + "%");
         }
 
-        return _vmGroupDao.search(sc, searchFilter);
+        Pair<List<InstanceGroupVO>, Integer> result = _vmGroupDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends InstanceGroup>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -3322,7 +3338,7 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<? extends SSHKeyPair> listSSHKeyPairs(ListSSHKeyPairsCmd cmd) {
+    public Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(ListSSHKeyPairsCmd cmd) {
         String name = cmd.getName();
         String fingerPrint = cmd.getFingerprint();
 
@@ -3349,7 +3365,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("fingerprint", SearchCriteria.Op.EQ, fingerPrint);
         }
 
-        return _sshKeyPairDao.search(sc, searchFilter);
+        Pair<List<SSHKeyPairVO>, Integer> result = _sshKeyPairDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends SSHKeyPair>, Integer>(result.first(), result.second());
     }
 
     @Override
@@ -3486,7 +3503,8 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public List<HypervisorCapabilitiesVO> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, String keyword, Long startIndex, Long pageSizeVal) {
+    public Pair<List<? extends HypervisorCapabilities>, Integer> listHypervisorCapabilities(Long id,
+            HypervisorType hypervisorType, String keyword, Long startIndex, Long pageSizeVal) {
         Filter searchFilter = new Filter(HypervisorCapabilitiesVO.class, "id", true, startIndex, pageSizeVal);
         SearchCriteria<HypervisorCapabilitiesVO> sc = _hypervisorCapabilitiesDao.createSearchCriteria();
 
@@ -3504,8 +3522,8 @@ public class ManagementServerImpl implements ManagementServer {
             sc.addAnd("hypervisorType", SearchCriteria.Op.SC, ssc);
         }
 
-        return _hypervisorCapabilitiesDao.search(sc, searchFilter);
-
+        Pair<List<HypervisorCapabilitiesVO>, Integer> result =  _hypervisorCapabilitiesDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<? extends HypervisorCapabilities>, Integer>(result.first(), result.second());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f5733ce/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index c2ae1bf..8c7b67f 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -441,7 +441,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
     }
 
     @Override
-    public List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name) {
+    public Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -477,7 +477,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
     }
 
     @Override
-    public List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId, String name, String state, Long startIndex, Long pageSize) {
+    public Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> listNetworkServiceProviders(Long physicalNetworkId, String name, String state, Long startIndex, Long pageSize) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -537,7 +537,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
     }
 
     @Override
-    public List<? extends PhysicalNetworkTrafficType> listTrafficTypes(Long physicalNetworkId) {
+    public Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId) {
         // TODO Auto-generated method stub
         return null;
     }


Mime
View raw message