Search in sources :

Example 6 with VpcResponse

use of com.cloud.api.response.VpcResponse in project cosmic by MissionCriticalCloud.

the class CreateVPCCmd method execute.

@Override
public void execute() {
    Vpc vpc = null;
    try {
        if (isStart()) {
            _vpcService.startVpc(getEntityId(), true);
        } else {
            s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API");
        }
        vpc = _entityMgr.findById(Vpc.class, getEntityId());
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final InsufficientCapacityException ex) {
        s_logger.info(ex.toString());
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
    if (vpc != null) {
        final VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) VpcResponse(com.cloud.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 7 with VpcResponse

use of com.cloud.api.response.VpcResponse in project cosmic by MissionCriticalCloud.

the class ListVPCsCmdByAdmin method execute.

@Override
public void execute() {
    final 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());
    final ListResponse<VpcResponse> response = new ListResponse<>();
    final List<VpcResponse> vpcResponses = new ArrayList<>();
    for (final Vpc vpc : vpcs.first()) {
        final VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Full, vpc);
        vpcResponses.add(offeringResponse);
    }
    response.setResponses(vpcResponses, vpcs.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) VpcResponse(com.cloud.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

VpcResponse (com.cloud.api.response.VpcResponse)7 Vpc (com.cloud.network.vpc.Vpc)6 ServerApiException (com.cloud.api.ServerApiException)4 ArrayList (java.util.ArrayList)3 ListResponse (com.cloud.api.response.ListResponse)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 List (java.util.List)2 NetworkResponse (com.cloud.api.response.NetworkResponse)1 PhysicalNetworkResponse (com.cloud.api.response.PhysicalNetworkResponse)1 ResourceTagResponse (com.cloud.api.response.ResourceTagResponse)1 ServiceResponse (com.cloud.api.response.ServiceResponse)1 DataCenter (com.cloud.dc.DataCenter)1 Network (com.cloud.network.Network)1 Service (com.cloud.network.Network.Service)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 VpcOffering (com.cloud.network.vpc.VpcOffering)1 ResourceTag (com.cloud.server.ResourceTag)1 EnumSet (java.util.EnumSet)1