Search in sources :

Example 46 with ListResponse

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;
}
Also used : StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO) ArrayList(java.util.ArrayList) List(java.util.List)

Example 47 with ListResponse

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());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) BaremetalRctResponse(com.cloud.baremetal.networkservice.BaremetalRctResponse) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 48 with ListResponse

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.");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) CiscoNexusVSMDevice(com.cloud.network.CiscoNexusVSMDevice) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) CiscoNexusVSMResponse(com.cloud.api.response.CiscoNexusVSMResponse)

Example 49 with ListResponse

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);
}
Also used : IsolationMethodResponse(org.apache.cloudstack.api.response.IsolationMethodResponse) Networks(com.cloud.network.Networks) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 50 with ListResponse

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);
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Aggregations

ListResponse (org.apache.cloudstack.api.response.ListResponse)177 ArrayList (java.util.ArrayList)160 List (java.util.List)70 ServerApiException (org.apache.cloudstack.api.ServerApiException)49 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)32 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 Account (com.cloud.user.Account)10 Network (com.cloud.network.Network)9 Host (com.cloud.host.Host)8 NetworkResponse (org.apache.cloudstack.api.response.NetworkResponse)8 Test (org.junit.Test)8 DedicatedResources (com.cloud.dc.DedicatedResources)7 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)7 TemplateResponse (org.apache.cloudstack.api.response.TemplateResponse)7 Domain (com.cloud.domain.Domain)6 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)5 ApiDiscoveryResponse (org.apache.cloudstack.api.response.ApiDiscoveryResponse)5 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)4 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4