CLOUDSTACK-9937 : dedicateCluster API response does not return correct detail in response

This commit is contained in:
Nitesh Sarda 2017-06-01 14:03:06 +05:30
parent 1bd66cb03e
commit 7364616aa4

View File

@ -105,14 +105,12 @@ public class DedicateClusterCmd extends BaseAsyncCmd {
List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName()); List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>(); ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>(); List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>();
if (result != null) {
for (DedicatedResources resource : result) { // List of result should always contain single element as only one cluster will be associated with each cluster ID.
DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource); if (result != null && result.size() == 1) {
clusterResponseList.add(clusterResponse); DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(result.get(0));
} clusterResponse.setResponseName(getCommandName());
response.setResponses(clusterResponseList); this.setResponseObject(clusterResponse);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else { } else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster"); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
} }