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