2323import com .cloud .exception .ResourceUnavailableException ;
2424import com .cloud .hypervisor .vmware .VmwareDatacenterService ;
2525import com .cloud .user .Account ;
26+ import com .cloud .utils .Pair ;
2627import com .cloud .utils .exception .CloudRuntimeException ;
2728import org .apache .cloudstack .api .APICommand ;
2829import org .apache .cloudstack .api .ApiConstants ;
3132import org .apache .cloudstack .api .BaseResponse ;
3233import org .apache .cloudstack .api .Parameter ;
3334import org .apache .cloudstack .api .ServerApiException ;
34- import org .apache .cloudstack .api .response .ListResponse ;
3535import org .apache .cloudstack .api .response .UnmanagedInstanceResponse ;
3636import org .apache .cloudstack .api .response .VmwareDatacenterResponse ;
3737import org .apache .cloudstack .vm .UnmanagedInstanceTO ;
@@ -73,11 +73,10 @@ public class ListVmwareDcVmsCmd extends BaseListCmd {
7373 @ Parameter (name = ApiConstants .PAGE_SIZE , type = CommandType .INTEGER , description = "The maximum number of results to return." )
7474 private Integer pageSize ;
7575
76- @ Parameter (name = ApiConstants .PAGE , type = CommandType .INTEGER ,
77- description = "For listVmwareDcVms, the maximum number of results to return is either 0, 1 or more." +
78- " When more than 1, the next page as returned by the vcenter will be propagated to the caller." +
79- " If no previous call has been done, this is the same as the first page" )
80- private Integer pageNumber ;
76+ @ Parameter (name = ApiConstants .TOKEN , type = CommandType .STRING ,
77+ description = "For listVmwareDcVms, if the maximum number of results (the `pagesize`) is exceeded, " +
78+ " a token is returned. This token can be used in subsequent calls to retrieve more results" )
79+ private String token ;
8180
8281 @ Parameter (name = ApiConstants .FORCED , type = CommandType .BOOLEAN , description = "force retrieving new results, ignoring any cached data." )
8382 private Boolean forced ;
@@ -94,16 +93,8 @@ public String getPassword() {
9493 return password ;
9594 }
9695
97- public Integer getPageSize () {
98- return pageSize ;
99- }
100-
101- public Integer getPageNumber () {
102- return pageNumber ;
103- }
104-
105- public boolean isForced () {
106- return forced == null ? true : forced ;
96+ public String getToken () {
97+ return token ;
10798 }
10899
109100 public String getDatacenterName () {
@@ -118,7 +109,8 @@ public Long getExistingVcenterId() {
118109 public void execute () throws ResourceUnavailableException , InsufficientCapacityException , ServerApiException , ConcurrentOperationException , ResourceAllocationException , NetworkRuleConflictException {
119110 checkParameters ();
120111 try {
121- List <UnmanagedInstanceTO > vms = _vmwareDatacenterService .listVMsInDatacenter (this );
112+ Pair <String , List <UnmanagedInstanceTO >> results = _vmwareDatacenterService .listVMsInDatacenter (this );
113+ List <UnmanagedInstanceTO > vms = results .second ();
122114 List <BaseResponse > baseResponseList = new ArrayList <>();
123115 if (CollectionUtils .isNotEmpty (vms )) {
124116 for (UnmanagedInstanceTO vmwareVm : vms ) {
@@ -130,9 +122,10 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
130122 if (CollectionUtils .isEmpty (pagingList )) {
131123 pagingList = baseResponseList ;
132124 }
133- ListResponse <BaseResponse > response = new ListResponse <>();
125+ VmwarRequestReponse <BaseResponse > response = new VmwarRequestReponse <>();
134126 response .setResponses (pagingList , baseResponseList .size ());
135127 response .setResponseName (getCommandName ());
128+ response .setToken (results .first ());
136129 setResponseObject (response );
137130 } catch (CloudRuntimeException e ) {
138131 String errorMsg = String .format ("Error retrieving VMs from VMware VC: %s" , e .getMessage ());
0 commit comments