Skip to content

Commit 9334e09

Browse files
niteshsardaRohit Yadav
authored andcommitted
CLOUDSTACK-9937 : dedicateCluster API response does not return correct detail in response
(cherry picked from commit 7364616) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent e574953 commit 9334e09

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,12 @@ public void execute() {
105105
List<? extends DedicatedResources> result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName());
106106
ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
107107
List<DedicateClusterResponse> clusterResponseList = new ArrayList<DedicateClusterResponse>();
108-
if (result != null) {
109-
for (DedicatedResources resource : result) {
110-
DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
111-
clusterResponseList.add(clusterResponse);
112-
}
113-
response.setResponses(clusterResponseList);
114-
response.setResponseName(getCommandName());
115-
this.setResponseObject(response);
108+
109+
// List of result should always contain single element as only one cluster will be associated with each cluster ID.
110+
if (result != null && result.size() == 1) {
111+
DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(result.get(0));
112+
clusterResponse.setResponseName(getCommandName());
113+
this.setResponseObject(clusterResponse);
116114
} else {
117115
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster");
118116
}

0 commit comments

Comments
 (0)