Search in sources :

Example 61 with ServerApiException

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

the class RemoveVpnUserCmd method execute.

@Override
public void execute() {
    Account owner = _accountService.getAccount(getEntityOwnerId());
    boolean result = _ravService.removeVpnUser(owner.getId(), userName, CallContext.current().getCallingAccount());
    if (!result) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user");
    }
    try {
        if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn user removal");
        }
    } catch (Exception ex) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user due to resource unavailable");
    }
    SuccessResponse response = new SuccessResponse(getCommandName());
    setResponseObject(response);
}
Also used : Account(com.cloud.user.Account) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 62 with ServerApiException

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

the class UpdateVpnCustomerGatewayCmd method execute.

@Override
public void execute() {
    Site2SiteCustomerGateway result = _s2sVpnService.updateCustomerGateway(this);
    if (result != null) {
        Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update customer VPN gateway");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) Site2SiteCustomerGatewayResponse(org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse) Site2SiteCustomerGateway(com.cloud.network.Site2SiteCustomerGateway)

Example 63 with ServerApiException

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

the class DeleteVpnCustomerGatewayCmd method execute.

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

Example 64 with ServerApiException

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

the class DeleteVpnGatewayCmd method execute.

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

Example 65 with ServerApiException

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

the class AddClusterCmdTest method testExecuteForNullResult.

@Test
public void testExecuteForNullResult() {
    ResourceService resourceService = Mockito.mock(ResourceService.class);
    try {
        Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(null);
    } catch (ResourceInUseException 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();
    }
    addClusterCmd._resourceService = resourceService;
    try {
        addClusterCmd.execute();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add cluster", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceInUseException(com.cloud.exception.ResourceInUseException) 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