Search in sources :

Example 6 with ResizeVolumeAnswer

use of com.cloud.agent.api.storage.ResizeVolumeAnswer in project cosmic by MissionCriticalCloud.

the class CitrixResizeVolumeCommandWrapper method execute.

@Override
public Answer execute(final ResizeVolumeCommand command, final CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    final String volid = command.getPath();
    final long newSize = command.getNewSize();
    try {
        final VDI vdi = citrixResourceBase.getVDIbyUuid(conn, volid);
        vdi.resize(conn, newSize);
        return new ResizeVolumeAnswer(command, true, "success", newSize);
    } catch (final Exception e) {
        s_logger.warn("Unable to resize volume", e);
        final String error = "failed to resize volume:" + e;
        return new ResizeVolumeAnswer(command, false, error);
    }
}
Also used : Connection(com.xensource.xenapi.Connection) VDI(com.xensource.xenapi.VDI) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer)

Example 7 with ResizeVolumeAnswer

use of com.cloud.agent.api.storage.ResizeVolumeAnswer 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)

Example 8 with ResizeVolumeAnswer

use of com.cloud.agent.api.storage.ResizeVolumeAnswer in project cloudstack by apache.

the class LinstorPrimaryDataStoreDriverImpl method notifyResize.

private CreateCmdResult notifyResize(DataObject data, long oldSize, ResizeVolumePayload resizeParameter) {
    VolumeObject vol = (VolumeObject) data;
    StoragePool pool = (StoragePool) data.getDataStore();
    ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), oldSize, resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName, null);
    CreateCmdResult result = new CreateCmdResult(null, null);
    try {
        ResizeVolumeAnswer answer = (ResizeVolumeAnswer) _storageMgr.sendToPool(pool, resizeParameter.hosts, resizeCmd);
        if (answer != null && answer.getResult()) {
            s_logger.debug("Resize: notified hosts");
        } 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 (Exception e) {
        s_logger.debug("sending resize command failed", e);
        result.setResult(e.toString());
    }
    return result;
}
Also used : StoragePool(com.cloud.storage.StoragePool) ResizeVolumeCommand(com.cloud.agent.api.storage.ResizeVolumeCommand) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) CreateCmdResult(org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult) VolumeObject(org.apache.cloudstack.storage.volume.VolumeObject) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ApiException(com.linbit.linstor.api.ApiException)

Aggregations

ResizeVolumeAnswer (com.cloud.agent.api.storage.ResizeVolumeAnswer)8 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 ResizeVolumeCommand (com.cloud.agent.api.storage.ResizeVolumeCommand)3 StoragePool (com.cloud.storage.StoragePool)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)2 ResizeVolumePayload (com.cloud.storage.ResizeVolumePayload)2 Script (com.cloud.utils.script.Script)2 Connection (com.xensource.xenapi.Connection)2 VDI (com.xensource.xenapi.VDI)2 CreateCmdResult (org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult)2 VolumeObject (org.apache.cloudstack.storage.volume.VolumeObject)2 Connect (org.libvirt.Connect)2 LibvirtException (org.libvirt.LibvirtException)2 StorageVol (org.libvirt.StorageVol)2 CreateCmdResult (com.cloud.engine.subsystem.api.storage.CreateCmdResult)1 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 KVMPhysicalDisk (com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk)1 KVMStoragePool (com.cloud.hypervisor.kvm.storage.KVMStoragePool)1