Search in sources :

Example 6 with VpcResponse

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

the class ListVPCsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@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.Restricted, 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) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with VpcResponse

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

the class UpdateVPCCmd method execute.

@Override
public void execute() {
    Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), getDisplayVpc());
    if (result != null) {
        VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) VpcResponse(org.apache.cloudstack.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc)

Aggregations

VpcResponse (org.apache.cloudstack.api.response.VpcResponse)7 Vpc (com.cloud.network.vpc.Vpc)6 ServerApiException (org.apache.cloudstack.api.ServerApiException)4 ArrayList (java.util.ArrayList)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 List (java.util.List)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 DataCenter (com.cloud.dc.DataCenter)1 Network (com.cloud.network.Network)1 Provider (com.cloud.network.Network.Provider)1 Service (com.cloud.network.Network.Service)1 OvsProvider (com.cloud.network.OvsProvider)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)1 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)1 VpcOffering (com.cloud.network.vpc.VpcOffering)1 ResourceTag (com.cloud.server.ResourceTag)1 EnumSet (java.util.EnumSet)1