Search in sources :

Example 61 with SuccessResponse

use of com.cloud.api.response.SuccessResponse in project cosmic by MissionCriticalCloud.

the class AssignToLoadBalancerRuleCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Load balancer Id: " + getLoadBalancerId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ","));
    final Map<Long, List<String>> vmIdIpsMap = getVmIdIpListMap();
    boolean result = false;
    try {
        result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap);
    } catch (final CloudRuntimeException ex) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign load balancer rule");
    }
    if (result) {
        final SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign load balancer rule");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 62 with SuccessResponse

use of com.cloud.api.response.SuccessResponse in project cosmic by MissionCriticalCloud.

the class DeleteLBHealthCheckPolicyCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Load balancer health check policy Id: " + getId());
    final boolean result = _lbService.deleteLBHealthCheckPolicy(getId(), true);
    if (result) {
        final SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer health check policy");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 63 with SuccessResponse

use of com.cloud.api.response.SuccessResponse in project cosmic by MissionCriticalCloud.

the class DeleteVPCCmd method execute.

@Override
public void execute() {
    try {
        final boolean result = _vpcService.deleteVpc(getId());
        if (result) {
            final SuccessResponse response = new SuccessResponse(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC");
        }
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 64 with SuccessResponse

use of com.cloud.api.response.SuccessResponse in project cosmic by MissionCriticalCloud.

the class RestartVPCCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    try {
        final boolean result = _vpcService.restartVpc(getId(), getCleanup());
        if (result) {
            final SuccessResponse response = new SuccessResponse(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart VPC");
        }
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final InsufficientCapacityException ex) {
        s_logger.info(ex.toString());
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 65 with SuccessResponse

use of com.cloud.api.response.SuccessResponse in project cosmic by MissionCriticalCloud.

the class DeleteVpnCustomerGatewayCmd method execute.

@Override
public void execute() {
    final boolean result = _s2sVpnService.deleteCustomerGateway(this);
    if (result) {
        final SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException)

Aggregations

SuccessResponse (com.cloud.api.response.SuccessResponse)136 ServerApiException (com.cloud.api.ServerApiException)128 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)10 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)8 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)3 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)3 StoragePool (com.cloud.storage.StoragePool)2 Account (com.cloud.user.Account)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SimulatorManager (com.cloud.agent.manager.SimulatorManager)1 AlertType (com.cloud.alert.AlertService.AlertType)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceInUseException (com.cloud.exception.ResourceInUseException)1 ResourceTag (com.cloud.server.ResourceTag)1 UserVm (com.cloud.uservm.UserVm)1 ComponentLocator (com.cloud.utils.component.ComponentLocator)1