Search in sources :

Example 1 with ExpandVolumeExternalDeviceJob

use of com.emc.storageos.volumecontroller.impl.externaldevice.job.ExpandVolumeExternalDeviceJob in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(StorageSystem storageSystem, StoragePool storagePool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("Volume expand ..... Started");
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    DriverTask task = null;
    try {
        // Prepare driver volume
        StorageVolume driverVolume = new StorageVolume();
        driverVolume.setNativeId(volume.getNativeId());
        driverVolume.setDeviceLabel(volume.getDeviceLabel());
        driverVolume.setStorageSystemId(storageSystem.getNativeId());
        driverVolume.setStoragePoolId(storagePool.getNativeId());
        driverVolume.setRequestedCapacity(volume.getCapacity());
        driverVolume.setThinlyProvisioned(volume.getThinlyProvisioned());
        driverVolume.setDisplayName(volume.getLabel());
        driverVolume.setAllocatedCapacity(volume.getAllocatedCapacity());
        driverVolume.setProvisionedCapacity(volume.getProvisionedCapacity());
        driverVolume.setWwn(volume.getWWN());
        // call driver
        task = driver.expandVolume(driverVolume, size);
        if (!isTaskInTerminalState(task.getStatus())) {
            // If the task is not in a terminal state and will be completed asynchronously
            // create a job to monitor the progress of the request and update the volume and
            // call the completer as appropriate based on the result of the request.
            ExpandVolumeExternalDeviceJob job = new ExpandVolumeExternalDeviceJob(storageSystem.getId(), volume.getId(), task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("doExpandVolume -- Expanded volume: %s .", task.getMessage());
            _log.info(msg);
            ExternalDeviceUtils.updateExpandedVolume(volume, driverVolume, dbClient);
            taskCompleter.ready(dbClient);
        } else {
            // operation failed
            String errorMsg = String.format("doExpandVolume -- Failed to expand volume: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.expandVolumeFailed("doExpandVolume", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        _log.error("doExpandVolume -- Failed to expand volume. ", e);
        ServiceError serviceError = ExternalDeviceException.errors.expandVolumeFailed("doExpandVolume", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        try {
            if (task == null || isTaskInTerminalState(task.getStatus())) {
                updateStoragePoolCapacity(storagePool, storageSystem, URIUtil.toUris(Collections.singletonList(volume)), dbClient);
            }
        } catch (Exception ex) {
            _log.error("Failed to update storage pool {} after expand volume operation completion.", storagePool.getId(), ex);
        }
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) ExpandVolumeExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.ExpandVolumeExternalDeviceJob)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)1 DriverTask (com.emc.storageos.storagedriver.DriverTask)1 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 ExpandVolumeExternalDeviceJob (com.emc.storageos.volumecontroller.impl.externaldevice.job.ExpandVolumeExternalDeviceJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 IOException (java.io.IOException)1