use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListStorageNetworkIpRangeCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<StorageNetworkIpRange> results = _storageNetworkService.listIpRange(this);
ListResponse<StorageNetworkIpRangeResponse> response = new ListResponse<StorageNetworkIpRangeResponse>();
List<StorageNetworkIpRangeResponse> resList = new ArrayList<StorageNetworkIpRangeResponse>(results.size());
for (StorageNetworkIpRange r : results) {
StorageNetworkIpRangeResponse resp = _responseGenerator.createStorageNetworkIpRangeResponse(r);
resList.add(resp);
}
response.setResponses(resList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to list storage network ip range for rangeId=" + getRangeId() + " podId=" + getPodId() + " zoneId=" + getZoneId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListOvsElementsCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<? extends OvsProvider> providers = _service.get(0).searchForOvsElement(this);
ListResponse<OvsProviderResponse> response = new ListResponse<OvsProviderResponse>();
List<OvsProviderResponse> providerResponses = new ArrayList<OvsProviderResponse>();
for (OvsProvider provider : providers) {
OvsProviderResponse providerResponse = _responseGenerator.createOvsProviderResponse(provider);
providerResponses.add(providerResponse);
}
response.setResponses(providerResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
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 {
if (this.getKeyword() != null && !this.getKeyword().isEmpty() && this.getNicId() != null) {
List<? extends NicSecondaryIp> results = _networkService.listVmNicSecondaryIps(this);
ListResponse<NicSecondaryIpResponse> response = new ListResponse<NicSecondaryIpResponse>();
List<NicSecondaryIpResponse> resList = new ArrayList<NicSecondaryIpResponse>();
NicSecondaryIpResponse res = new NicSecondaryIpResponse();
List<NicSecondaryIpResponse> res_List = new ArrayList<NicSecondaryIpResponse>();
if (results != null) {
for (NicSecondaryIp r : results) {
NicSecondaryIpResponse ipRes = _responseGenerator.createSecondaryIPToNicResponse(r);
resList.add(ipRes);
res.setSecondaryIpsList(resList);
res.setObjectName("nic");
}
res_List.add(res);
response.setResponses(res_List);
}
response.setResponses(res_List);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
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());
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListSSHKeyPairsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
Pair<List<? extends SSHKeyPair>, Integer> resultList = _mgr.listSSHKeyPairs(this);
List<SSHKeyPairResponse> responses = new ArrayList<SSHKeyPairResponse>();
for (SSHKeyPair result : resultList.first()) {
SSHKeyPairResponse r = _responseGenerator.createSSHKeyPairResponse(result, false);
r.setObjectName("sshkeypair");
responses.add(r);
}
ListResponse<SSHKeyPairResponse> response = new ListResponse<SSHKeyPairResponse>();
response.setResponses(responses, resultList.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListRegionsCmd method execute.
@Override
public void execute() {
List<? extends Region> result = _regionService.listRegions(this);
ListResponse<RegionResponse> response = new ListResponse<RegionResponse>();
List<RegionResponse> regionResponses = new ArrayList<RegionResponse>();
for (Region region : result) {
RegionResponse regionResponse = _responseGenerator.createRegionResponse(region);
regionResponse.setObjectName("region");
regionResponses.add(regionResponse);
}
response.setResponses(regionResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations