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;
}
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);
}
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");
}
}
Aggregations