Search in sources :

Example 41 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class PrimaryDataStoreHelper method disable.

public boolean disable(DataStore store) {
    StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
    pool.setStatus(StoragePoolStatus.Disabled);
    this.dataStoreDao.update(pool.getId(), pool);
    return true;
}
Also used : StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO)

Example 42 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class HypervDirectConnectResourceTest method testCreateStoragePoolCommand.

@Test
public final void testCreateStoragePoolCommand() {
    String folderName = "." + File.separator + "Dummy";
    StoragePoolVO pool = createTestStoragePoolVO(folderName);
    CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
    s_logger.debug("TestCreateStoragePoolCommand sending " + s_gson.toJson(cmd));
    Answer ans = s_hypervresource.executeRequest(cmd);
    Assert.assertTrue(ans.getResult());
}
Also used : StopAnswer(com.cloud.agent.api.StopAnswer) Answer(com.cloud.agent.api.Answer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand) Test(org.junit.Test)

Example 43 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class Ovm3StorageProcessorTest method copyVolumeCommandTest.

@Test
public void copyVolumeCommandTest() throws ConfigurationException {
    con = prepare();
    String src = linux.getVirtualDisksDir() + ovmObject.newUuid() + ".raw";
    String dst = linux.getVirtualDisksDir() + ovmObject.newUuid() + ".raw";
    StoragePoolVO poolio = new StoragePoolVO();
    CopyVolumeCommand copy = new CopyVolumeCommand(0, src, poolio, dst, true, 0, false);
    Answer ra = hypervisor.executeRequest(copy);
    results.basicBooleanTest(ra.getResult());
    copy = new CopyVolumeCommand(0, src, poolio, dst, false, 0, false);
    ra = hypervisor.executeRequest(copy);
    results.basicBooleanTest(ra.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) CopyVolumeCommand(com.cloud.agent.api.storage.CopyVolumeCommand) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) Test(org.junit.Test) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) StoragePluginTest(com.cloud.hypervisor.ovm3.objects.StoragePluginTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 44 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method deleteVolume.

private void deleteVolume(VolumeInfo volumeInfo, long storagePoolId) {
    try {
        long volumeId = volumeInfo.getId();
        SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao);
        if (isBasicDeleteByFolder(volumeId)) {
            performBasicDeleteByFolder(sfConnection, volumeId);
        } else if (isBasicDelete(volumeId)) {
            performBasicDelete(sfConnection, volumeId);
        } else if (isBasicDeleteFailure(volumeId)) {
            performBasicDeleteFailure(sfConnection, volumeId);
        } else {
            deleteSolidFireVolume(sfConnection, volumeInfo);
            volumeDetailsDao.removeDetails(volumeId);
            StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId);
            long usedBytes = getUsedBytes(storagePool, volumeId);
            storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes);
            storagePoolDao.update(storagePoolId, storagePool);
        }
    } catch (Exception ex) {
        LOGGER.debug(SolidFireUtil.LOG_PREFIX + "Failed to delete SolidFire volume. CloudStack volume ID: " + volumeInfo.getId(), ex);
        throw ex;
    }
}
Also used : VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) SolidFireUtil(org.apache.cloudstack.storage.datastore.util.SolidFireUtil) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 45 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method takeSnapshot.

@Override
public void takeSnapshot(SnapshotInfo snapshotInfo, AsyncCompletionCallback<CreateCmdResult> callback) {
    CreateCmdResult result;
    try {
        VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
        VolumeVO volumeVO = volumeDao.findById(volumeInfo.getId());
        long sfVolumeId = Long.parseLong(volumeVO.getFolder());
        long storagePoolId = volumeVO.getPoolId();
        SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao);
        SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getVolume(sfConnection, sfVolumeId);
        StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId);
        long capacityBytes = storagePool.getCapacityBytes();
        // getUsedBytes(StoragePool) will not include the bytes of the proposed new volume or snapshot because
        // updateSnapshotDetails has not yet been called for this new volume or snapshot
        long usedBytes = getUsedBytes(storagePool);
        long sfVolumeSize = sfVolume.getTotalSize();
        usedBytes += sfVolumeSize;
        // that is serving as the volume the snapshot is of (either a new SolidFire volume or a SolidFire snapshot).
        if (usedBytes > capacityBytes) {
            throw new CloudRuntimeException("Insufficient amount of space remains in this primary storage to take a snapshot");
        }
        storagePool.setUsedBytes(usedBytes);
        SnapshotObjectTO snapshotObjectTo = (SnapshotObjectTO) snapshotInfo.getTO();
        if (shouldTakeSnapshot(snapshotInfo.getId())) {
            // We are supposed to take a SolidFire snapshot to serve as the back-end for our CloudStack volume snapshot.
            String sfNewSnapshotName = volumeInfo.getName() + "-" + snapshotInfo.getUuid();
            int maxSnapshotNameLength = 64;
            int trimRequired = sfNewSnapshotName.length() - maxSnapshotNameLength;
            if (trimRequired > 0) {
                sfNewSnapshotName = StringUtils.left(volumeInfo.getName(), (volumeInfo.getName().length() - trimRequired)) + "-" + snapshotInfo.getUuid();
            }
            long sfNewSnapshotId = SolidFireUtil.createSnapshot(sfConnection, sfVolumeId, SolidFireUtil.getSolidFireVolumeName(sfNewSnapshotName), getSnapshotAttributes(snapshotInfo));
            updateSnapshotDetails(snapshotInfo.getId(), volumeInfo.getId(), sfVolumeId, sfNewSnapshotId, storagePoolId, sfVolumeSize);
            snapshotObjectTo.setPath("SfSnapshotId=" + sfNewSnapshotId);
        } else {
            // We are supposed to create a new SolidFire volume to serve as the back-end for our CloudStack volume snapshot.
            String sfNewVolumeName = volumeInfo.getName() + "-" + snapshotInfo.getUuid();
            final Iops iops = getIops(MIN_IOPS_FOR_SNAPSHOT_VOLUME, MAX_IOPS_FOR_SNAPSHOT_VOLUME, storagePoolId);
            long sfNewVolumeId = SolidFireUtil.createVolume(sfConnection, SolidFireUtil.getSolidFireVolumeName(sfNewVolumeName), sfVolume.getAccountId(), sfVolumeSize, sfVolume.isEnable512e(), getSnapshotAttributes(snapshotInfo), iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
            SolidFireUtil.SolidFireVolume sfNewVolume = SolidFireUtil.getVolume(sfConnection, sfNewVolumeId);
            updateSnapshotDetails(snapshotInfo.getId(), sfNewVolumeId, storagePoolId, sfVolumeSize, sfNewVolume.getIqn());
            snapshotObjectTo.setPath("SfVolumeId=" + sfNewVolumeId);
        }
        // Now that we have successfully created a volume or a snapshot, update the space usage in the cloud.storage_pool table
        // (even though cloud.storage_pool.used_bytes is likely no longer in use).
        storagePoolDao.update(storagePoolId, storagePool);
        CreateObjectAnswer createObjectAnswer = new CreateObjectAnswer(snapshotObjectTo);
        result = new CreateCmdResult(null, createObjectAnswer);
        result.setResult(null);
    } catch (Exception ex) {
        LOGGER.debug(SolidFireUtil.LOG_PREFIX + "Failed to take CloudStack snapshot: " + snapshotInfo.getId(), ex);
        result = new CreateCmdResult(null, new CreateObjectAnswer(ex.toString()));
        result.setResult(ex.toString());
    }
    callback.complete(result);
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) CreateCmdResult(org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) SolidFireUtil(org.apache.cloudstack.storage.datastore.util.SolidFireUtil)

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