Search in sources :

Example 81 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListVlanIpRangesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends Vlan>, Integer> vlans = _mgr.searchForVlans(this);
    ListResponse<VlanIpRangeResponse> response = new ListResponse<VlanIpRangeResponse>();
    List<VlanIpRangeResponse> vlanResponses = new ArrayList<VlanIpRangeResponse>();
    for (Vlan vlan : vlans.first()) {
        VlanIpRangeResponse vlanResponse = _responseGenerator.createVlanIpRangeResponse(vlan);
        vlanResponse.setObjectName("vlaniprange");
        vlanResponses.add(vlanResponse);
    }
    response.setResponses(vlanResponses, vlans.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VlanIpRangeResponse(org.apache.cloudstack.api.response.VlanIpRangeResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Vlan(com.cloud.dc.Vlan)

Example 82 with ListResponse

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);
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) StorageProviderResponse(org.apache.cloudstack.api.response.StorageProviderResponse)

Example 83 with ListResponse

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

Example 84 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListAutoScalePoliciesCmd method execute.

@Override
public void execute() {
    List<? extends AutoScalePolicy> autoScalePolicies = _autoScaleService.listAutoScalePolicies(this);
    ListResponse<AutoScalePolicyResponse> response = new ListResponse<AutoScalePolicyResponse>();
    List<AutoScalePolicyResponse> responses = new ArrayList<AutoScalePolicyResponse>();
    if (autoScalePolicies != null) {
        for (AutoScalePolicy autoScalePolicy : autoScalePolicies) {
            AutoScalePolicyResponse autoScalePolicyResponse = _responseGenerator.createAutoScalePolicyResponse(autoScalePolicy);
            autoScalePolicyResponse.setObjectName("autoscalepolicy");
            responses.add(autoScalePolicyResponse);
        }
    }
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : AutoScalePolicyResponse(org.apache.cloudstack.api.response.AutoScalePolicyResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) AutoScalePolicy(com.cloud.network.as.AutoScalePolicy) ArrayList(java.util.ArrayList)

Example 85 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListCountersCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends Counter> counters = null;
    counters = _autoScaleService.listCounters(this);
    ListResponse<CounterResponse> response = new ListResponse<CounterResponse>();
    List<CounterResponse> ctrResponses = new ArrayList<CounterResponse>();
    for (Counter ctr : counters) {
        CounterResponse ctrResponse = _responseGenerator.createCounterResponse(ctr);
        ctrResponses.add(ctrResponse);
    }
    response.setResponses(ctrResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Counter(com.cloud.network.as.Counter) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) CounterResponse(org.apache.cloudstack.api.response.CounterResponse)

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