use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class QueryManagerImpl method searchForStoragePools.
@Override
public ListResponse<StoragePoolResponse> searchForStoragePools(ListStoragePoolsCmd cmd) {
Pair<List<StoragePoolJoinVO>, Integer> result = searchForStoragePoolsInternal(cmd);
ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(result.first().toArray(new StoragePoolJoinVO[result.first().size()]));
for (StoragePoolResponse poolResponse : poolResponses) {
DataStore store = dataStoreManager.getPrimaryDataStore(poolResponse.getId());
if (store != null) {
DataStoreDriver driver = store.getDriver();
if (driver != null && driver.getCapabilities() != null) {
Map<String, String> caps = driver.getCapabilities();
if (Storage.StoragePoolType.NetworkFilesystem.toString().equals(poolResponse.getType()) && HypervisorType.VMware.toString().equals(poolResponse.getHypervisor())) {
StoragePoolVO pool = _storagePoolDao.findPoolByUUID(poolResponse.getId());
StoragePoolDetailVO detail = _storagePoolDetailsDao.findDetail(pool.getId(), Storage.Capability.HARDWARE_ACCELERATION.toString());
if (detail != null) {
caps.put(Storage.Capability.HARDWARE_ACCELERATION.toString(), detail.getValue());
}
}
poolResponse.setCaps(caps);
}
}
}
response.setResponses(poolResponses, result.second());
return response;
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListBaremetalRctCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
ListResponse<BaremetalRctResponse> response = new ListResponse<>();
List<BaremetalRctResponse> rctResponses = new ArrayList<>();
BaremetalRctResponse rsp = vlanMgr.listRct();
if (rsp != null) {
rctResponses.add(rsp);
}
response.setResponses(rctResponses);
response.setResponseName(getCommandName());
response.setObjectName("baremetalrcts");
this.setResponseObject(response);
} catch (Exception e) {
s_logger.debug("Exception happened while executing ListBaremetalRctCmd", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListCiscoNexusVSMsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
// NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
// automagically gets translated to the corresponding db id before this execute() method
// is invoked. That's the reason why we don't have any uuid-dbid translation code here.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<? extends CiscoNexusVSMDevice> vsmDeviceList = _ciscoNexusVSMService.getCiscoNexusVSMs(this);
if (vsmDeviceList.size() > 0) {
ListResponse<CiscoNexusVSMResponse> response = new ListResponse<CiscoNexusVSMResponse>();
List<CiscoNexusVSMResponse> vsmResponses = new ArrayList<CiscoNexusVSMResponse>();
for (CiscoNexusVSMDevice vsmDevice : vsmDeviceList) {
CiscoNexusVSMResponse vsmresponse = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(vsmDevice);
vsmresponse.setObjectName("cisconexusvsm");
response.setResponseName(getCommandName());
vsmResponses.add(vsmresponse);
}
response.setResponses(vsmResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "No VSM found.");
}
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListNetworkIsolationMethodsCmd method execute.
@Override
public void execute() {
Networks.IsolationType[] methods = _ntwkModel.listNetworkIsolationMethods();
ListResponse<IsolationMethodResponse> response = new ListResponse<IsolationMethodResponse>();
List<IsolationMethodResponse> isolationResponses = new ArrayList<IsolationMethodResponse>();
if (methods != null) {
for (Networks.IsolationType method : methods) {
IsolationMethodResponse isolationMethod = _responseGenerator.createIsolationMethodResponse(method);
isolationResponses.add(isolationMethod);
}
}
response.setResponses(isolationResponses, isolationResponses.size());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListNetworkServiceProvidersCmd method execute.
@Override
public void execute() {
Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId(), getName(), getState(), this.getStartIndex(), this.getPageSizeVal());
ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders.first()) {
ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
serviceProvidersResponses.add(serviceProviderResponse);
}
response.setResponses(serviceProvidersResponses, serviceProviders.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations