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