use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class RegisterIsoCmd method execute.
@Override
public void execute() throws ResourceAllocationException {
VirtualMachineTemplate template = _templateService.registerIso(this);
if (template != null) {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(template.getId(), zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register iso");
}
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListVpnUsersCmd method execute.
@Override
public void execute() {
List<? extends VpnUser> vpnUsers = _ravService.searchForVpnUsers(this);
ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
for (VpnUser vpnUser : vpnUsers) {
vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
}
response.setResponses(vpnResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListSupportedNetworkServicesCmd method execute.
@Override
public void execute() {
List<? extends Network.Service> services;
if (getServiceName() != null) {
Network.Service service = null;
if (serviceName != null) {
service = Network.Service.getService(serviceName);
if (service == null) {
throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
}
}
List<Network.Service> serviceList = new ArrayList<Network.Service>();
serviceList.add(service);
services = serviceList;
} else {
services = _networkService.listNetworkServices(getProviderName());
}
ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>();
List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>();
for (Network.Service service : services) {
//skip gateway service
if (service == Service.Gateway) {
continue;
}
ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
servicesResponses.add(serviceResponse);
}
response.setResponses(servicesResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
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;
}
}
Aggregations