use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class AddVmwareDcCmd method execute.
@Override
public void execute() {
try {
VmwareDatacenterResponse response = new VmwareDatacenterResponse();
VmwareDatacenterVO result = _vmwareDatacenterService.addVmwareDatacenter(this);
if (result != null) {
response.setId(result.getUuid());
response.setName(result.getVmwareDatacenterName());
response.setResponseName(getCommandName());
response.setObjectName("vmwaredc");
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add VMware Datacenter to zone.");
}
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
for (String proxyObj : ex.getIdProxyList()) {
e.addProxyObject(proxyObj);
}
throw e;
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException(ex.getMessage());
} catch (CloudRuntimeException runtimeEx) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeEx.getMessage());
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class ListVmwareDcsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<? extends VmwareDatacenter> vmwareDcList = null;
try {
vmwareDcList = _vmwareDatacenterService.listVmwareDatacenters(this);
} catch (InvalidParameterValueException ie) {
throw new InvalidParameterValueException("Invalid zone id " + getZoneId());
} catch (Exception e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to find associated VMware DCs associated with zone " + getZoneId());
}
ListResponse<VmwareDatacenterResponse> response = new ListResponse<VmwareDatacenterResponse>();
List<VmwareDatacenterResponse> vmwareDcResponses = new ArrayList<VmwareDatacenterResponse>();
if (vmwareDcList != null && vmwareDcList.size() > 0) {
for (VmwareDatacenter vmwareDc : vmwareDcList) {
VmwareDatacenterResponse vmwareDcResponse = new VmwareDatacenterResponse();
vmwareDcResponse.setId(vmwareDc.getUuid());
vmwareDcResponse.setVcenter(vmwareDc.getVcenterHost());
vmwareDcResponse.setName(vmwareDc.getVmwareDatacenterName());
vmwareDcResponse.setZoneId(getZoneId());
vmwareDcResponse.setObjectName("VMwareDC");
vmwareDcResponses.add(vmwareDcResponse);
}
}
response.setResponses(vmwareDcResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class AddExternalFirewallCmd method execute.
@SuppressWarnings("deprecation")
@Override
public void execute() {
try {
Host externalFirewall = _srxElementService.addExternalFirewall(this);
ExternalFirewallResponse response = _srxElementService.createExternalFirewallResponse(externalFirewall);
response.setObjectName("externalfirewall");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DeleteSrxFirewallCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
boolean result = _srxElementService.deleteSrxFirewall(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete SRX firewall device");
}
} 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 ConfigureNetscalerLoadBalancerCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
ExternalLoadBalancerDeviceVO lbDeviceVO = _netsclarLbService.configureNetscalerLoadBalancer(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 configure 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());
}
}
Aggregations