use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListSwiftsCmd method execute.
@Override
public void execute() {
List<? extends Swift> result = _resourceService.listSwifts(this);
ListResponse<SwiftResponse> response = new ListResponse<SwiftResponse>();
List<SwiftResponse> swiftResponses = new ArrayList<SwiftResponse>();
if (result != null) {
SwiftResponse swiftResponse = null;
for (Swift swift : result) {
swiftResponse = _responseGenerator.createSwiftResponse(swift);
swiftResponse.setResponseName(getCommandName());
swiftResponse.setObjectName("swift");
swiftResponses.add(swiftResponse);
}
}
response.setResponses(swiftResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class AddClusterCmd method execute.
@Override
public void execute() {
try {
List<? extends Cluster> result = _resourceService.discoverCluster(this);
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
if (result != null) {
for (Cluster cluster : result) {
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
clusterResponses.add(clusterResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
}
response.setResponses(clusterResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
ServerApiException e = new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
for (IdentityProxy proxyObj : ex.getIdProxyList()) {
e.addProxyObject(proxyObj.getTableName(), proxyObj.getValue(), proxyObj.getidFieldName());
}
throw e;
}
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class AddHostCmd method execute.
@Override
public void execute() {
try {
List<? extends Host> result = _resourceService.discoverHosts(this);
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
if (result != null && result.size() > 0) {
for (Host host : result) {
HostResponse hostResponse = _responseGenerator.createHostResponse(host);
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListEventTypesCmd method execute.
@Override
public void execute() {
String[] result = _mgr.listEventTypes();
ListResponse<EventTypeResponse> response = new ListResponse<EventTypeResponse>();
ArrayList<EventTypeResponse> responses = new ArrayList<EventTypeResponse>();
if (result != null) {
for (String eventType : result) {
EventTypeResponse eventTypeResponse = new EventTypeResponse();
eventTypeResponse.setName(eventType);
eventTypeResponse.setObjectName("eventtype");
responses.add(eventTypeResponse);
}
}
response.setResponses(responses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListEventsCmd method execute.
@Override
public void execute() {
List<? extends Event> result = _mgr.searchForEvents(this);
ListResponse<EventResponse> response = new ListResponse<EventResponse>();
List<EventResponse> eventResponses = new ArrayList<EventResponse>();
for (Event event : result) {
eventResponses.add(_responseGenerator.createEventResponse(event));
}
response.setResponses(eventResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations