use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.
the class StorageSystemDataMotionStrategyTest method configureAndVerifyIsSourceAndDestinationPoolTypeOfNfs.
private void configureAndVerifyIsSourceAndDestinationPoolTypeOfNfs(StoragePoolType destStoragePoolType, StoragePoolType sourceStoragePoolType, boolean expected) {
VolumeInfo srcVolumeInfo = Mockito.mock(VolumeObject.class);
Mockito.lenient().when(srcVolumeInfo.getId()).thenReturn(0l);
DataStore destDataStore = Mockito.mock(PrimaryDataStoreImpl.class);
Mockito.when(destDataStore.getId()).thenReturn(1l);
StoragePoolVO destStoragePool = Mockito.mock(StoragePoolVO.class);
Mockito.when(destStoragePool.getPoolType()).thenReturn(destStoragePoolType);
StoragePoolVO sourceStoragePool = Mockito.mock(StoragePoolVO.class);
Mockito.when(sourceStoragePool.getPoolType()).thenReturn(sourceStoragePoolType);
Map<VolumeInfo, DataStore> volumeDataStoreMap = new HashMap<>();
volumeDataStoreMap.put(srcVolumeInfo, destDataStore);
Mockito.doReturn(sourceStoragePool).when(primaryDataStoreDao).findById(0l);
Mockito.doReturn(destStoragePool).when(primaryDataStoreDao).findById(1l);
boolean result = strategy.isSourceAndDestinationPoolTypeOfNfs(volumeDataStoreMap);
Assert.assertEquals(expected, result);
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.
the class TemplateDataFactoryImpl method getReadyBypassedTemplateOnManagedStorage.
@Override
public TemplateInfo getReadyBypassedTemplateOnManagedStorage(long templateId, TemplateInfo templateOnPrimary, Long poolId, Long hostId) {
VMTemplateVO templateVO = imageDataDao.findById(templateId);
if (templateVO == null || !templateVO.isDirectDownload()) {
return null;
}
if (poolId == null) {
throw new CloudRuntimeException("No storage pool specified to download template: " + templateId);
}
StoragePoolVO poolVO = primaryDataStoreDao.findById(poolId);
if (poolVO == null || !poolVO.isManaged()) {
return null;
}
VMTemplateStoragePoolVO spoolRef = templatePoolDao.findByPoolTemplate(poolId, templateId, null);
if (spoolRef == null) {
throw new CloudRuntimeException("Template not created on managed storage pool: " + poolId + " to copy the download template: " + templateId);
} else if (spoolRef.getDownloadState() == VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED) {
directDownloadManager.downloadTemplate(templateId, poolId, hostId);
}
DataStore store = storeMgr.getDataStore(poolId, DataStoreRole.Primary);
return this.getTemplate(templateId, store);
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.
the class VolumeServiceImpl method deleteVolumeCallback.
public Void deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback, DeleteVolumeContext<VolumeApiResult> context) {
CommandResult result = callback.getResult();
VolumeObject vo = context.getVolume();
VolumeApiResult apiResult = new VolumeApiResult(vo);
try {
if (result.isSuccess()) {
vo.processEvent(Event.OperationSuccessed);
if (canVolumeBeRemoved(vo.getId())) {
s_logger.info("Volume " + vo.getId() + " is not referred anywhere, remove it from volumes table");
volDao.remove(vo.getId());
}
SnapshotDataStoreVO snapStoreVo = _snapshotStoreDao.findByVolume(vo.getId(), DataStoreRole.Primary);
if (snapStoreVo != null) {
long storagePoolId = snapStoreVo.getDataStoreId();
StoragePoolVO storagePoolVO = storagePoolDao.findById(storagePoolId);
if (storagePoolVO.isManaged()) {
DataStore primaryDataStore = dataStoreMgr.getPrimaryDataStore(storagePoolId);
Map<String, String> mapCapabilities = primaryDataStore.getDriver().getCapabilities();
String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
Boolean supportsStorageSystemSnapshots = new Boolean(value);
if (!supportsStorageSystemSnapshots) {
_snapshotStoreDao.remove(snapStoreVo.getId());
}
} else {
_snapshotStoreDao.remove(snapStoreVo.getId());
}
}
} else {
vo.processEvent(Event.OperationFailed);
apiResult.setResult(result.getResult());
}
} catch (Exception e) {
s_logger.debug("ignore delete volume status update failure, it will be picked up by storage clean up thread later", e);
}
context.getFuture().complete(apiResult);
return null;
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.
the class NotAValidCommand method testDestroyCommand.
@Test
public void testDestroyCommand() {
final VMTemplateStorageResourceAssoc templateStorage = Mockito.mock(VMTemplateStorageResourceAssoc.class);
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final DestroyCommand destroyCommand = new DestroyCommand(poolVO, templateStorage);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(destroyCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.
the class NotAValidCommand method testExecuteCreateCommand.
@Test
public void testExecuteCreateCommand() {
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final DiskProfile diskProfile = Mockito.mock(DiskProfile.class);
final CreateCommand createCommand = new CreateCommand(diskProfile, "", poolVO, false);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(createCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
Aggregations