use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListStorageProvidersCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
if (getType() == null) {
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "need to specify type: either primary or image");
}
List<StorageProviderResponse> providers = this.dataStoreProviderApiService.getDataStoreProviders(getType());
ListResponse<StorageProviderResponse> responses = new ListResponse<StorageProviderResponse>();
for (StorageProviderResponse provider : providers) {
provider.setObjectName("dataStoreProvider");
}
responses.setResponses(providers);
responses.setResponseName(this.getCommandName());
this.setResponseObject(responses);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListSystemVMsCmd method execute.
@Override
public void execute() {
Pair<List<? extends VirtualMachine>, Integer> systemVMs = _mgr.searchForSystemVm(this);
ListResponse<SystemVmResponse> response = new ListResponse<SystemVmResponse>();
List<SystemVmResponse> vmResponses = new ArrayList<SystemVmResponse>();
for (VirtualMachine systemVM : systemVMs.first()) {
SystemVmResponse vmResponse = _responseGenerator.createSystemVmResponse(systemVM);
vmResponse.setObjectName("systemvm");
vmResponses.add(vmResponse);
}
response.setResponses(vmResponses, systemVMs.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class PrepareTemplateCmd method execute.
@Override
public void execute() {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId, storageId);
List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, vmTemplate, zoneId, true);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class RegisterTemplateCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
try {
VirtualMachineTemplate template = _templateService.registerTemplate(this);
if (template != null) {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template, zoneId, false);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template");
}
} catch (URISyntaxException ex1) {
s_logger.info(ex1);
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex1.getMessage());
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListNicsCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
try {
List<? extends Nic> results = _networkService.listNics(this);
ListResponse<NicResponse> response = new ListResponse<NicResponse>();
List<NicResponse> resList = null;
if (results != null) {
resList = new ArrayList<NicResponse>(results.size());
for (Nic r : results) {
NicResponse resp = _responseGenerator.createNicResponse(r);
resp.setObjectName("nic");
resList.add(resp);
}
response.setResponses(resList);
}
response.setResponses(resList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to list secondary ip address per nic ");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Aggregations