use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DeleteLBStickinessPolicyCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Load balancer stickiness policy ID: " + getId());
boolean result = _lbService.deleteLBStickinessPolicy(getId(), true);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer stickiness policy");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class UpdateLoadBalancerRuleCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Load balancer ID: " + getId());
LoadBalancer result = _lbService.updateLoadBalancerRule(this);
if (result != null) {
LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update load balancer rule");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class UploadSslCertCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
SslCertResponse response = _certService.uploadSslCert(this);
setResponseObject(response);
response.setResponseName(getCommandName());
} catch (Exception e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class RemoveFromLoadBalancerRuleCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Load balancer Id: " + getId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ","));
Map<Long, List<String>> vmIdIpsMap = getVmIdIpListMap();
try {
boolean result = _lbService.removeFromLoadBalancer(id, virtualMachineIds, vmIdIpsMap);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove instance from load balancer rule");
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Failed to remove instance from load balancer rule");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DetachIsoCmd method execute.
@Override
public void execute() {
boolean result = _templateService.detachIso(virtualMachineId);
if (result) {
UserVm userVm = _entityMgr.findById(UserVm.class, virtualMachineId);
UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm).get(0);
response.setResponseName(DeployVMCmd.getResultObjectName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach ISO");
}
}
Aggregations