Search in sources :

Example 31 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse 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");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 32 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeleteEventsCmd method execute.

@Override
public void execute() {
    if (ids == null && type == null && endDate == null) {
        throw new InvalidParameterValueException("either ids, type or enddate must be specified");
    } else if (startDate != null && endDate == null) {
        throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
    }
    boolean result = _mgr.deleteEvents(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Events, one or more parameters has invalid values");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 33 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeleteFirewallRuleCmd method execute.

@Override
public void execute() throws ResourceUnavailableException {
    CallContext.current().setEventDetails("Rule Id: " + id);
    boolean result = _firewallService.revokeIngressFwRule(id, true);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete firewall rule");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 34 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class RemoveVmwareDcCmd method execute.

@Override
public void execute() {
    SuccessResponse response = new SuccessResponse();
    try {
        boolean result = _vmwareDatacenterService.removeVmwareDatacenter(this);
        if (result) {
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove VMware datacenter from zone");
        }
    } catch (ResourceInUseException ex) {
        s_logger.warn("The zone has one or more resources (like cluster), hence not able to remove VMware datacenter from zone." + " Please remove all resource from zone, and retry. 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());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceInUseException(com.cloud.exception.ResourceInUseException)

Example 35 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeleteF5LoadBalancerCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        boolean result = _f5DeviceManagerService.deleteF5LoadBalancer(this);
        if (result) {
            SuccessResponse response = new SuccessResponse(getCommandName());
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete F5 load balancer.");
        }
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)137 ServerApiException (org.apache.cloudstack.api.ServerApiException)125 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)26 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)6 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)5 ResourceInUseException (com.cloud.exception.ResourceInUseException)4 ArrayList (java.util.ArrayList)3 Role (org.apache.cloudstack.acl.Role)3 Account (com.cloud.user.Account)2 List (java.util.List)2 RolePermission (org.apache.cloudstack.acl.RolePermission)2 Domain (com.cloud.domain.Domain)1 Host (com.cloud.host.Host)1 ResourceTag (com.cloud.server.ResourceTag)1 StoragePool (com.cloud.storage.StoragePool)1 UserAccount (com.cloud.user.UserAccount)1