Search in sources :

Example 1 with PrivateGatewayResponse

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

the class ListPrivateGatewaysCmd method execute.

@Override
public void execute() {
    final Pair<List<PrivateGateway>, Integer> gateways = _vpcService.listPrivateGateway(this);
    final ListResponse<PrivateGatewayResponse> response = new ListResponse<>();
    final List<PrivateGatewayResponse> projectResponses = new ArrayList<>();
    for (final PrivateGateway gateway : gateways.first()) {
        final PrivateGatewayResponse gatewayResponse = _responseGenerator.createPrivateGatewayResponse(gateway);
        projectResponses.add(gatewayResponse);
    }
    response.setResponses(projectResponses, gateways.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : PrivateGatewayResponse(com.cloud.api.response.PrivateGatewayResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PrivateGateway(com.cloud.network.vpc.PrivateGateway)

Example 2 with PrivateGatewayResponse

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

the class ApiResponseHelper method createPrivateGatewayResponse.

@Override
public PrivateGatewayResponse createPrivateGatewayResponse(final PrivateGateway result) {
    final PrivateGatewayResponse response = new PrivateGatewayResponse();
    response.setId(result.getUuid());
    if (result.getVpcId() != null) {
        final Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
        response.setVpcId(vpc.getUuid());
    }
    final DataCenter zone = ApiDBUtils.findZoneById(result.getZoneId());
    if (zone != null) {
        response.setZoneId(zone.getUuid());
        response.setZoneName(zone.getName());
    }
    response.setAddress(result.getIp4Address());
    final Network network = ApiDBUtils.findNetworkById(result.getNetworkId());
    response.setNetworkId(network.getUuid());
    response.setNetworkName(network.getName());
    response.setCidr(network.getCidr());
    populateAccount(response, result.getAccountId());
    populateDomain(response, result.getDomainId());
    response.setState(result.getState().toString());
    response.setSourceNat(result.getSourceNat());
    final NetworkACL acl = ApiDBUtils.findByNetworkACLId(result.getNetworkACLId());
    if (acl != null) {
        response.setAclId(acl.getUuid());
    }
    response.setObjectName("privategateway");
    return response;
}
Also used : PrivateGatewayResponse(com.cloud.api.response.PrivateGatewayResponse) DataCenter(com.cloud.dc.DataCenter) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Vpc(com.cloud.network.vpc.Vpc) NetworkACL(com.cloud.network.vpc.NetworkACL)

Example 3 with PrivateGatewayResponse

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

the class CreatePrivateGatewayCmd method execute.

@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException, ResourceUnavailableException {
    final PrivateGateway result = _vpcService.applyVpcPrivateGateway(getEntityId(), true);
    if (result != null) {
        final PrivateGatewayResponse response = _responseGenerator.createPrivateGatewayResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway");
    }
}
Also used : PrivateGatewayResponse(com.cloud.api.response.PrivateGatewayResponse) ServerApiException(com.cloud.api.ServerApiException) PrivateGateway(com.cloud.network.vpc.PrivateGateway)

Aggregations

PrivateGatewayResponse (com.cloud.api.response.PrivateGatewayResponse)3 PrivateGateway (com.cloud.network.vpc.PrivateGateway)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 DataCenter (com.cloud.dc.DataCenter)1 Network (com.cloud.network.Network)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 NetworkACL (com.cloud.network.vpc.NetworkACL)1 Vpc (com.cloud.network.vpc.Vpc)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1