use of com.cloud.legacymodel.storage.Volume in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testDestroyCommandError.
@Test
public void testDestroyCommandError() {
final StoragePool pool = Mockito.mock(StoragePool.class);
final Volume volume = Mockito.mock(Volume.class);
final String vmName = "Test";
final DestroyCommand command = new DestroyCommand(pool, volume, vmName);
final KvmStoragePoolManager poolManager = Mockito.mock(KvmStoragePoolManager.class);
final KvmStoragePool primary = Mockito.mock(KvmStoragePool.class);
final VolumeTO vol = command.getVolume();
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
when(poolManager.getStoragePool(vol.getPoolType(), vol.getPoolUuid())).thenReturn(primary);
when(primary.deletePhysicalDisk(vol.getPath(), null)).thenThrow(CloudRuntimeException.class);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid());
}
use of com.cloud.legacymodel.storage.Volume in project cosmic by MissionCriticalCloud.
the class DetachVolumeCmdByAdmin method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
final Volume result = _volumeService.detachVolumeFromVM(this);
if (result != null) {
final VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
response.setResponseName("volume");
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume");
}
}
use of com.cloud.legacymodel.storage.Volume in project cosmic by MissionCriticalCloud.
the class ResizeVolumeCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
Volume volume = null;
try {
CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
volume = _volumeService.resizeVolume(this);
} catch (final InvalidParameterValueException ex) {
s_logger.info(ex.getMessage());
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
}
if (volume != null) {
final VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
// FIXME - have to be moved to ApiResponseHelper
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume");
}
}
use of com.cloud.legacymodel.storage.Volume in project cosmic by MissionCriticalCloud.
the class UploadVolumeCmdByAdmin method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
final Volume volume = _volumeService.uploadVolume(this);
if (volume != null) {
final VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume");
}
}
use of com.cloud.legacymodel.storage.Volume in project cosmic by MissionCriticalCloud.
the class MigrateVolumeCmdByAdmin method execute.
@Override
public void execute() {
final Volume result;
result = _volumeService.migrateVolume(this);
if (result != null) {
final VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume");
}
}
Aggregations