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");
}
}
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");
}
}
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());
}
}
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");
}
}
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());
}
}
Aggregations