use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DeleteNetscalerLoadBalancerCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
boolean result = _netsclarLbService.deleteNetscalerLoadBalancer(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete netscaler load balancer.");
}
} 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.ServerApiException in project cloudstack by apache.
the class ListSrxFirewallNetworksCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
List<? extends Network> networks = _srxFwService.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.ServerApiException in project cloudstack by apache.
the class AddNetscalerLoadBalancerCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _netsclarLbService.addNetscalerLoadBalancer(this);
if (lbDeviceVO != null) {
NetscalerLoadBalancerResponse response = _netsclarLbService.createNetscalerLoadBalancerResponse(lbDeviceVO);
response.setObjectName("netscalerloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add netscaler load balancer due to internal error.");
}
} 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.ServerApiException in project cloudstack by apache.
the class RegisterNetscalerControlCenterCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
NetScalerControlCenterVO nccVO = _netsclarLbService.registerNetscalerControlCenter(this);
if (nccVO != null) {
NetscalerControlCenterResponse response = _netsclarLbService.createNetscalerControlCenterResponse(nccVO);
response.setObjectName("netscalerloadbalancer");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add netscaler load balancer due to internal error.");
}
} 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.ServerApiException in project cloudstack by apache.
the class StopNetScalerVMCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("NetScaler vm Id: " + getId());
VirtualRouter result = null;
VirtualRouter vm = _routerService.findRouter(getId());
if (vm == null || vm.getRole() != Role.NETSCALER_VM) {
throw new InvalidParameterValueException("Can't find NetScaler lb vm by id");
} else {
result = _netsclarLbService.stopNetscalerServiceVm(getId(), isForced(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
}
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop Netscaler vm");
}
}
Aggregations