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);
}
}
}
Aggregations