Search in sources :

Example 41 with SuccessResponse

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

the class ExpungeVMCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
    CallContext.current().setEventDetails("Vm Id: " + getId());
    try {
        UserVm result = _userVmService.expungeVm(this.getId());
        if (result != null) {
            SuccessResponse response = new SuccessResponse(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge vm");
        }
    } catch (InvalidParameterValueException ipve) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
    } catch (CloudRuntimeException cre) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 42 with SuccessResponse

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

the class DeleteZoneCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Zone Id: " + getId());
    boolean result = _configService.deleteZone(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete zone");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 43 with SuccessResponse

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

the class AddAccountToProjectCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    if (accountName == null && email == null) {
        throw new InvalidParameterValueException("Either accountName or email is required");
    }
    CallContext.current().setEventDetails("Project ID: " + projectId + "; accountName " + accountName);
    boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName(), getEmail());
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add account to the project");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 44 with SuccessResponse

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

the class DeletePrivateGatewayCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
    CallContext.current().setEventDetails("Network ACL Id: " + id);
    boolean result = _vpcService.deleteVpcPrivateGateway(id);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete private gateway");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 45 with SuccessResponse

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

the class DeleteVPCOfferingCmd method execute.

@Override
public void execute() {
    boolean result = _vpcProvSvc.deleteVpcOffering(getId());
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC offering");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

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