Search in sources :

Example 1 with PrivateGatewayResponse

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

the class ApiResponseHelper method createPrivateGatewayResponse.

@Override
public PrivateGatewayResponse createPrivateGatewayResponse(PrivateGateway result) {
    PrivateGatewayResponse response = new PrivateGatewayResponse();
    response.setId(result.getUuid());
    response.setBroadcastUri(result.getBroadcastUri());
    response.setGateway(result.getGateway());
    response.setNetmask(result.getNetmask());
    if (result.getVpcId() != null) {
        Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
        response.setVpcId(vpc.getUuid());
        response.setVpcName(vpc.getName());
    }
    DataCenter zone = ApiDBUtils.findZoneById(result.getZoneId());
    if (zone != null) {
        response.setZoneId(zone.getUuid());
        response.setZoneName(zone.getName());
    }
    response.setAddress(result.getIp4Address());
    PhysicalNetwork pnet = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
    if (pnet != null) {
        response.setPhysicalNetworkId(pnet.getUuid());
    }
    populateAccount(response, result.getAccountId());
    populateDomain(response, result.getDomainId());
    response.setState(result.getState().toString());
    response.setSourceNat(result.getSourceNat());
    NetworkACL acl = ApiDBUtils.findByNetworkACLId(result.getNetworkACLId());
    if (acl != null) {
        response.setAclId(acl.getUuid());
        response.setAclName(acl.getName());
    }
    response.setObjectName("privategateway");
    return response;
}
Also used : PrivateGatewayResponse(org.apache.cloudstack.api.response.PrivateGatewayResponse) DataCenter(com.cloud.dc.DataCenter) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Vpc(com.cloud.network.vpc.Vpc) NetworkACL(com.cloud.network.vpc.NetworkACL)

Example 2 with PrivateGatewayResponse

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

the class ListPrivateGatewaysCmd method execute.

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

Example 3 with PrivateGatewayResponse

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

the class CreatePrivateGatewayCmd method execute.

@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException, ResourceUnavailableException {
    PrivateGateway result = _vpcService.applyVpcPrivateGateway(getEntityId(), true);
    if (result != null) {
        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(org.apache.cloudstack.api.response.PrivateGatewayResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) PrivateGateway(com.cloud.network.vpc.PrivateGateway)

Aggregations

PrivateGatewayResponse (org.apache.cloudstack.api.response.PrivateGatewayResponse)3 PrivateGateway (com.cloud.network.vpc.PrivateGateway)2 DataCenter (com.cloud.dc.DataCenter)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 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1