Search in sources :

Example 1 with VolumeObject

use of com.cloud.storage.volume.VolumeObject in project cosmic by MissionCriticalCloud.

the class PrimaryDataStoreImpl method getVolume.

@Override
public VolumeInfo getVolume(final long id) {
    final VolumeVO volumeVO = volumeDao.findById(id);
    final VolumeObject vol = VolumeObject.getVolumeObject(this, volumeVO);
    return vol;
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) VolumeObject(com.cloud.storage.volume.VolumeObject)

Example 2 with VolumeObject

use of com.cloud.storage.volume.VolumeObject in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreDriverImpl method resize.

@Override
public void resize(final DataObject data, final AsyncCompletionCallback<CreateCmdResult> callback) {
    final VolumeObject vol = (VolumeObject) data;
    final StoragePool pool = (StoragePool) data.getDataStore();
    final ResizeVolumePayload resizeParameter = (ResizeVolumePayload) vol.getpayload();
    final ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(), resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName);
    final CreateCmdResult result = new CreateCmdResult(null, null);
    try {
        final ResizeVolumeAnswer answer = (ResizeVolumeAnswer) storageMgr.sendToPool(pool, resizeParameter.hosts, resizeCmd);
        if (answer != null && answer.getResult()) {
            final long finalSize = answer.getNewSize();
            s_logger.debug("Resize: volume started at size " + vol.getSize() + " and ended at size " + finalSize);
            vol.setSize(finalSize);
            vol.update();
        } else if (answer != null) {
            result.setResult(answer.getDetails());
        } else {
            s_logger.debug("return a null answer, mark it as failed for unknown reason");
            result.setResult("return a null answer, mark it as failed for unknown reason");
        }
    } catch (final Exception e) {
        s_logger.debug("sending resize command failed", e);
        result.setResult(e.toString());
    }
    callback.complete(result);
}
Also used : StoragePool(com.cloud.storage.StoragePool) ResizeVolumeCommand(com.cloud.agent.api.storage.ResizeVolumeCommand) ResizeVolumePayload(com.cloud.storage.ResizeVolumePayload) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) CreateCmdResult(com.cloud.engine.subsystem.api.storage.CreateCmdResult) VolumeObject(com.cloud.storage.volume.VolumeObject) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) StorageUnavailableException(com.cloud.exception.StorageUnavailableException)

Aggregations

VolumeObject (com.cloud.storage.volume.VolumeObject)2 ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)1 ResizeVolumeCommand (com.cloud.agent.api.storage.ResizeVolumeCommand)1 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)1 CreateCmdResult (com.cloud.engine.subsystem.api.storage.CreateCmdResult)1 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)1 ResizeVolumePayload (com.cloud.storage.ResizeVolumePayload)1 StoragePool (com.cloud.storage.StoragePool)1 VolumeVO (com.cloud.storage.VolumeVO)1