use of org.apache.cloudstack.api.response.NetworkResponse in project cloudstack by apache.
the class UpdateNetworkCmdByAdmin method execute.
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException {
User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId());
Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId());
Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Couldn't find network by id");
}
Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId(), getUpdateInSequence(), getForced());
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network");
}
}
use of org.apache.cloudstack.api.response.NetworkResponse in project cloudstack by apache.
the class CreateNetworkCmdByAdmin method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public // an exception thrown by createNetwork() will be caught by the dispatcher.
void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
Network result = _networkService.createGuestNetwork(this);
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network");
}
}
use of org.apache.cloudstack.api.response.NetworkResponse in project cloudstack by apache.
the class UpdateNetworkCmd method execute.
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException {
Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Couldn't find network by ID");
}
Network result = _networkService.updateGuestNetwork(this);
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(getResponseView(), result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network");
}
}
use of org.apache.cloudstack.api.response.NetworkResponse in project cloudstack by apache.
the class ListF5LoadBalancerNetworksCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<? extends Network> networks = _f5DeviceManagerService.listNetworks(this);
ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
if (networks != null && !networks.isEmpty()) {
for (Network network : networks) {
NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
networkResponses.add(networkResponse);
}
}
response.setResponses(networkResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
use of org.apache.cloudstack.api.response.NetworkResponse in project cloudstack by apache.
the class ListNetscalerLoadBalancerNetworksCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<? extends Network> networks = _netsclarLbService.listNetworks(this);
ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
if (networks != null && !networks.isEmpty()) {
for (Network network : networks) {
NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network);
networkResponses.add(networkResponse);
}
}
response.setResponses(networkResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
Aggregations