Search in sources :

Example 51 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class UpdateDiskOfferingCmd method execute.

@Override
public void execute() {
    DiskOffering result = _configService.updateDiskOffering(this);
    if (result != null) {
        DiskOfferingResponse response = _responseGenerator.createDiskOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update disk offering");
    }
}
Also used : DiskOffering(com.cloud.offering.DiskOffering) ServerApiException(org.apache.cloudstack.api.ServerApiException) DiskOfferingResponse(org.apache.cloudstack.api.response.DiskOfferingResponse)

Example 52 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class UpdatePodCmd method execute.

@Override
public void execute() {
    Pod result = _configService.editPod(this);
    if (result != null) {
        PodResponse response = _responseGenerator.createPodResponse(result, false);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update pod");
    }
}
Also used : Pod(com.cloud.dc.Pod) ServerApiException(org.apache.cloudstack.api.ServerApiException) PodResponse(org.apache.cloudstack.api.response.PodResponse)

Example 53 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class CreatePortableIpRangeCmd method create.

@Override
public void create() throws ResourceAllocationException {
    try {
        PortableIpRange portableIpRange = _configService.createPortableIpRange(this);
        if (portableIpRange != null) {
            this.setEntityId(portableIpRange.getId());
            this.setEntityUuid(portableIpRange.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create portable public IP range");
        }
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) PortableIpRange(org.apache.cloudstack.region.PortableIpRange)

Example 54 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class DeletePortableIpRangeCmd method execute.

@Override
public void execute() {
    boolean result = _configService.deletePortableIpRange(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete portable ip range");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 55 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class AddHostCmdTest method testExecuteForNullResult.

@Test
public void testExecuteForNullResult() {
    ResourceService resourceService = Mockito.mock(ResourceService.class);
    addHostCmd._resourceService = resourceService;
    try {
        Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(null);
    } catch (InvalidParameterValueException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DiscoveryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        addHostCmd.execute();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add host", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceService(com.cloud.resource.ResourceService) DiscoveryException(com.cloud.exception.DiscoveryException) Test(org.junit.Test)

Aggregations

ServerApiException (org.apache.cloudstack.api.ServerApiException)513 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)125 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)116 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)61 ArrayList (java.util.ArrayList)58 UserVm (com.cloud.uservm.UserVm)44 ListResponse (org.apache.cloudstack.api.response.ListResponse)44 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)42 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)39 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)33 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)26 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)25 Account (com.cloud.user.Account)24 Host (com.cloud.host.Host)20 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)18 Volume (com.cloud.storage.Volume)16 Test (org.junit.Test)16 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)15 VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)15 UserAccount (com.cloud.user.UserAccount)13