Search in sources :

Example 91 with ListResponse

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

the class ListVPCOfferingsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(this);
    ListResponse<VpcOfferingResponse> response = new ListResponse<VpcOfferingResponse>();
    List<VpcOfferingResponse> offeringResponses = new ArrayList<VpcOfferingResponse>();
    for (VpcOffering offering : offerings.first()) {
        VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses, offerings.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) VpcOffering(com.cloud.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 92 with ListResponse

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

the class ListVpnUsersCmd method execute.

@Override
public void execute() {
    Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
    ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
    List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
    for (VpnUser vpnUser : vpnUsers.first()) {
        vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
    }
    response.setResponses(vpnResponses, vpnUsers.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : VpnUser(com.cloud.network.VpnUser) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) VpnUsersResponse(org.apache.cloudstack.api.response.VpnUsersResponse)

Example 93 with ListResponse

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

the class ListLunsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<LunVO> lunList = netappMgr.listLunsOnFiler(poolName);
        ListResponse<ListLunsCmdResponse> listResponse = new ListResponse<ListLunsCmdResponse>();
        List<ListLunsCmdResponse> responses = new ArrayList<ListLunsCmdResponse>();
        for (LunVO lun : lunList) {
            ListLunsCmdResponse response = new ListLunsCmdResponse();
            response.setId(lun.getId());
            response.setIqn(lun.getTargetIqn());
            response.setName(lun.getLunName());
            response.setVolumeId(lun.getVolumeId());
            response.setObjectName("lun");
            responses.add(response);
        }
        listResponse.setResponses(responses);
        listResponse.setResponseName(getCommandName());
        this.setResponseObject(listResponse);
    } catch (InvalidParameterValueException e) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, e.toString());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ListLunsCmdResponse(com.cloud.server.api.response.netapp.ListLunsCmdResponse) ArrayList(java.util.ArrayList) LunVO(com.cloud.netapp.LunVO)

Example 94 with ListResponse

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

the class ListVolumePoolsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<PoolVO> poolList = netappMgr.listPools();
        ListResponse<ListVolumePoolsCmdResponse> listResponse = new ListResponse<ListVolumePoolsCmdResponse>();
        List<ListVolumePoolsCmdResponse> responses = new ArrayList<ListVolumePoolsCmdResponse>();
        for (PoolVO pool : poolList) {
            ListVolumePoolsCmdResponse response = new ListVolumePoolsCmdResponse();
            response.setId(pool.getId());
            response.setName(pool.getName());
            response.setAlgorithm(pool.getAlgorithm());
            response.setObjectName("pool");
            responses.add(response);
        }
        listResponse.setResponses(responses);
        listResponse.setResponseName(getCommandName());
        this.setResponseObject(listResponse);
    } catch (InvalidParameterValueException e) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, e.toString());
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PoolVO(com.cloud.netapp.PoolVO) ListVolumePoolsCmdResponse(com.cloud.server.api.response.netapp.ListVolumePoolsCmdResponse) ArrayList(java.util.ArrayList)

Example 95 with ListResponse

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

the class ListVPCsCmdByAdmin method execute.

@Override
public void execute() {
    Pair<List<? extends Vpc>, Integer> vpcs = _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(), listAll(), getRestartRequired(), getTags(), getProjectId(), getDisplay());
    ListResponse<VpcResponse> response = new ListResponse<VpcResponse>();
    List<VpcResponse> vpcResponses = new ArrayList<VpcResponse>();
    for (Vpc vpc : vpcs.first()) {
        VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Full, vpc);
        vpcResponses.add(offeringResponse);
    }
    response.setResponses(vpcResponses, vpcs.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) VpcResponse(org.apache.cloudstack.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

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