Search in sources :

Example 81 with StoragePoolVO

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);
}
Also used : HashMap(java.util.HashMap) PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)

Example 82 with StoragePoolVO

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);
}
Also used : VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO)

Example 83 with StoragePoolVO

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;
}
Also used : PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StorageAccessException(com.cloud.exception.StorageAccessException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) CommandResult(org.apache.cloudstack.storage.command.CommandResult)

Example 84 with StoragePoolVO

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());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) DestroyCommand(com.cloud.agent.api.storage.DestroyCommand) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VMTemplateStorageResourceAssoc(com.cloud.storage.VMTemplateStorageResourceAssoc) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 85 with StoragePoolVO

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());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CreateCommand(com.cloud.agent.api.storage.CreateCommand) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) DiskProfile(com.cloud.vm.DiskProfile) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)276 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)106 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)75 ArrayList (java.util.ArrayList)54 VolumeVO (com.cloud.storage.VolumeVO)53 HostVO (com.cloud.host.HostVO)46 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)45 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)45 HashMap (java.util.HashMap)44 Answer (com.cloud.agent.api.Answer)38 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)35 StoragePool (com.cloud.storage.StoragePool)33 Test (org.junit.Test)33 VMInstanceVO (com.cloud.vm.VMInstanceVO)25 Map (java.util.Map)25 Account (com.cloud.user.Account)24 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)20 ExecutionException (java.util.concurrent.ExecutionException)20 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)19 ClusterVO (com.cloud.dc.ClusterVO)18