Search in sources :

Example 66 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class UploadCustomCertificateCmd method execute.

@Override
public void execute() {
    String result = _mgr.uploadCertificate(this);
    if (result != null) {
        CustomCertificateResponse response = new CustomCertificateResponse();
        response.setResponseName(getCommandName());
        response.setResultMessage(result);
        response.setObjectName("customcertificate");
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upload custom certificate");
    }
}
Also used : CustomCertificateResponse(com.cloud.api.response.CustomCertificateResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 67 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class RegisterTemplateCmd method execute.

@Override
public void execute() throws ResourceAllocationException {
    try {
        VirtualMachineTemplate template = _templateService.registerTemplate(this);
        if (template != null) {
            ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
            List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template.getId(), zoneId, false);
            response.setResponses(templateResponses);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
        }
    } catch (URISyntaxException ex1) {
        s_logger.info(ex1);
        throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse) URISyntaxException(java.net.URISyntaxException)

Example 68 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class RestartNetworkCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
    boolean result = _networkService.restartNetwork(this, getCleanup());
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to restart network");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 69 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class RevokeSecurityGroupEgressCmd method execute.

@Override
public void execute() {
    boolean result = _securityGroupService.revokeSecurityGroupEgress(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to revoke security group egress rule");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 70 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class StopRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    UserContext.current().setEventDetails("Router Id: " + getId());
    VirtualRouter result = _routerService.stopRouter(getId(), isForced());
    if (result != null) {
        DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

ServerApiException (com.cloud.api.ServerApiException)170 SuccessResponse (com.cloud.api.response.SuccessResponse)46 UserVm (com.cloud.uservm.UserVm)15 UserVmResponse (com.cloud.api.response.UserVmResponse)14 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)12 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)12 Account (com.cloud.user.Account)9 Host (com.cloud.host.Host)8 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)8 ListResponse (com.cloud.api.response.ListResponse)7 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)7 HostResponse (com.cloud.api.response.HostResponse)6 TemplateResponse (com.cloud.api.response.TemplateResponse)6 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)6 AccountResponse (com.cloud.api.response.AccountResponse)5 SystemVmResponse (com.cloud.api.response.SystemVmResponse)5 UserResponse (com.cloud.api.response.UserResponse)5 VolumeResponse (com.cloud.api.response.VolumeResponse)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)5