diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java index 9ef642e8d31..edc85610efe 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java @@ -105,14 +105,12 @@ public class DedicateClusterCmd extends BaseAsyncCmd { List result = dedicatedService.dedicateCluster(getClusterId(), getDomainId(), getAccountName()); ListResponse response = new ListResponse(); List clusterResponseList = new ArrayList(); - if (result != null) { - for (DedicatedResources resource : result) { - DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource); - clusterResponseList.add(clusterResponse); - } - response.setResponses(clusterResponseList); - response.setResponseName(getCommandName()); - this.setResponseObject(response); + + // List of result should always contain single element as only one cluster will be associated with each cluster ID. + if (result != null && result.size() == 1) { + DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(result.get(0)); + clusterResponse.setResponseName(getCommandName()); + this.setResponseObject(clusterResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate cluster"); }