Search in sources :

Example 26 with QueueJob

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

the class ExternalBlockStorageDevice method doCreateClone.

@Override
public void doCreateClone(StorageSystem storageSystem, URI volume, URI clone, Boolean createInactive, TaskCompleter taskCompleter) {
    Volume cloneObject = null;
    DriverTask task = null;
    try {
        cloneObject = dbClient.queryObject(Volume.class, clone);
        BlockObject sourceVolume = BlockObject.fetch(dbClient, volume);
        VolumeClone driverClone = new VolumeClone();
        if (sourceVolume instanceof Volume) {
            driverClone.setSourceType(VolumeClone.SourceType.VOLUME);
        } else if (sourceVolume instanceof BlockSnapshot) {
            driverClone.setSourceType(VolumeClone.SourceType.SNAPSHOT);
        } else {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
            String errorMsg = String.format("doCreateClone -- Failed to create volume clone: unexpected source type %s .", sourceVolume.getClass().getSimpleName());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        // Prepare driver clone
        driverClone.setParentId(sourceVolume.getNativeId());
        driverClone.setStorageSystemId(storageSystem.getNativeId());
        driverClone.setDisplayName(cloneObject.getLabel());
        driverClone.setRequestedCapacity(cloneObject.getCapacity());
        driverClone.setThinlyProvisioned(cloneObject.getThinlyProvisioned());
        // Call driver
        BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
        List<VolumeClone> driverClones = new ArrayList<>();
        driverClones.add(driverClone);
        task = driver.createVolumeClone(Collections.unmodifiableList(driverClones), null);
        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 clone
            // volume and call the completer as appropriate based on the result of the request.
            CreateVolumeCloneExternalDeviceJob job = new CreateVolumeCloneExternalDeviceJob(storageSystem.getId(), clone, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // Update clone
            String msg = String.format("doCreateClone -- Created volume clone: %s .", task.getMessage());
            _log.info(msg);
            VolumeClone driverCloneResult = driverClones.get(0);
            ExternalDeviceUtils.updateNewlyCreatedClone(cloneObject, driverCloneResult, dbClient);
            taskCompleter.ready(dbClient);
        } else {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
            String errorMsg = String.format("doCreateClone -- Failed to create volume clone: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        if (cloneObject != null) {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
        }
        _log.error("Failed to create volume clone. ", e);
        ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        try {
            if (task == null || isTaskInTerminalState(task.getStatus())) {
                StoragePool dbPool = dbClient.queryObject(StoragePool.class, cloneObject.getPool());
                updateStoragePoolCapacity(dbPool, storageSystem, Collections.singletonList(clone), dbClient);
            }
        } catch (Exception ex) {
            _log.error("Failed to update storage pool {} after create clone operation completion.", cloneObject.getPool(), ex);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) CreateVolumeCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.CreateVolumeCloneExternalDeviceJob) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 27 with QueueJob

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

the class ExternalBlockStorageDevice method doRestoreFromSnapshot.

@Override
public void doRestoreFromSnapshot(StorageSystem storageSystem, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    String storageSystemNativeId = storageSystem.getNativeId();
    _log.info("Snapshot Restore..... Started");
    BlockConsistencyGroup parentVolumeConsistencyGroup = null;
    try {
        List<BlockSnapshot> snapshotsToRestore = new ArrayList<>();
        BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
        List<BlockSnapshot> groupSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(blockSnapshot, dbClient);
        if (groupSnapshots.size() > 1 && ControllerUtils.checkSnapshotsInConsistencyGroup(Arrays.asList(blockSnapshot), dbClient, taskCompleter)) {
            // make sure we restore only snapshots from the same consistency group
            for (BlockSnapshot snap : groupSnapshots) {
                if (snap.getConsistencyGroup().equals(blockSnapshot.getConsistencyGroup())) {
                    snapshotsToRestore.add(snap);
                }
            }
            URI cgUri = blockSnapshot.getConsistencyGroup();
            parentVolumeConsistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
            _log.info("Restore group snapshot: group {}, snapshot set: {}, snapshots to restore: " + Joiner.on("\t").join(snapshotsToRestore), parentVolumeConsistencyGroup.getNativeId(), blockSnapshot.getReplicationGroupInstance());
        } else {
            Volume sourceVolume = getSnapshotParentVolume(blockSnapshot);
            snapshotsToRestore.add(blockSnapshot);
            _log.info("Restore single volume snapshot: volume {}, snapshot: {}", sourceVolume.getNativeId(), blockSnapshot.getNativeId());
        }
        // Prepare driver snapshots
        List<VolumeSnapshot> driverSnapshots = new ArrayList<>();
        for (BlockSnapshot snap : snapshotsToRestore) {
            VolumeSnapshot driverSnapshot = new VolumeSnapshot();
            Volume sourceVolume = getSnapshotParentVolume(snap);
            driverSnapshot.setParentId(sourceVolume.getNativeId());
            driverSnapshot.setNativeId(snap.getNativeId());
            driverSnapshot.setStorageSystemId(storageSystemNativeId);
            driverSnapshot.setDisplayName(snap.getLabel());
            if (parentVolumeConsistencyGroup != null) {
                driverSnapshot.setConsistencyGroup(snap.getReplicationGroupInstance());
            }
            driverSnapshots.add(driverSnapshot);
        }
        // Call driver to execute this request
        BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
        DriverTask task = driver.restoreSnapshot(driverSnapshots);
        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 call the completer as
            // appropriate based on the result of the request.
            RestoreFromSnapshotExternalDeviceJob job = new RestoreFromSnapshotExternalDeviceJob(storageSystem.getId(), snapshot, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("doRestoreFromSnapshot -- Restored snapshots: %s .", task.getMessage());
            _log.info(msg);
            taskCompleter.ready(dbClient);
        } else {
            String errorMsg = String.format("doRestoreFromSnapshot -- Failed to restore from snapshots: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.restoreFromSnapshotFailed("doRestoreFromSnapshot", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        String message = String.format("IO exception when trying to restore from snapshots on array %s", storageSystem.getSerialNumber());
        _log.error(message, e);
        ServiceError error = ExternalDeviceException.errors.restoreFromSnapshotFailed("doRestoreFromSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
    _log.info("Snapshot Restore..... End");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RestoreFromSnapshotExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.RestoreFromSnapshotExternalDeviceJob) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 28 with QueueJob

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

the class ExternalBlockStorageDevice method doCreateGroupClone.

@Override
public void doCreateGroupClone(StorageSystem storageSystem, List<URI> cloneURIs, Boolean createInactive, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    List<VolumeClone> driverClones = new ArrayList<>();
    Map<VolumeClone, Volume> driverCloneToCloneMap = new HashMap<>();
    Set<URI> consistencyGroups = new HashSet<>();
    List<Volume> clones = null;
    DriverTask task = null;
    try {
        clones = dbClient.queryObject(Volume.class, cloneURIs);
        // We assume here that all volumes belong to the same consistency group
        URI parentUri = clones.get(0).getAssociatedSourceVolume();
        Volume parentVolume = dbClient.queryObject(Volume.class, parentUri);
        BlockConsistencyGroup cg = null;
        if (!NullColumnValueGetter.isNullURI(parentVolume.getConsistencyGroup())) {
            cg = dbClient.queryObject(BlockConsistencyGroup.class, parentVolume.getConsistencyGroup());
        } else {
            String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone, parent volumes do not belong to consistency group." + " Clones: %s .", cloneURIs);
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        // Prepare driver consistency group of parent volume
        VolumeConsistencyGroup driverCG = new VolumeConsistencyGroup();
        driverCG.setDisplayName(cg.getLabel());
        driverCG.setNativeId(cg.getNativeId());
        driverCG.setStorageSystemId(storageSystem.getNativeId());
        // Prepare driver clones
        for (Volume clone : clones) {
            URI sourceVolumeUri = clone.getAssociatedSourceVolume();
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeUri);
            VolumeClone driverClone = new VolumeClone();
            driverClone.setParentId(sourceVolume.getNativeId());
            driverClone.setStorageSystemId(storageSystem.getNativeId());
            driverClone.setDisplayName(clone.getLabel());
            driverClone.setRequestedCapacity(clone.getCapacity());
            driverClone.setThinlyProvisioned(clone.getThinlyProvisioned());
            driverClones.add(driverClone);
            driverCloneToCloneMap.put(driverClone, clone);
        }
        // Call driver to create group snapshot
        task = driver.createConsistencyGroupClone(driverCG, Collections.unmodifiableList(driverClones), null);
        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 clone
            // volume and call the completer as appropriate based on the result of the request.
            CreateGroupCloneExternalDeviceJob job = new CreateGroupCloneExternalDeviceJob(storageSystem.getId(), cloneURIs, parentVolume.getConsistencyGroup(), task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // Update clone object with driver data
            String msg = String.format("doCreateGroupClone -- Created group clone: %s .", task.getMessage());
            _log.info(msg);
            List<Volume> cloneObjects = new ArrayList<>();
            for (VolumeClone driverCloneResult : driverClones) {
                Volume cloneObject = driverCloneToCloneMap.get(driverCloneResult);
                ExternalDeviceUtils.updateNewlyCreatedGroupClone(cloneObject, driverCloneResult, parentVolume.getConsistencyGroup(), dbClient);
                cloneObjects.add(cloneObject);
            }
            dbClient.updateObject(cloneObjects);
            taskCompleter.ready(dbClient);
        } else {
            // Process failure
            for (Volume cloneObject : clones) {
                cloneObject.setInactive(true);
            }
            dbClient.updateObject(clones);
            String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        if (clones != null) {
            // Process failure
            for (Volume cloneObject : clones) {
                cloneObject.setInactive(true);
            }
            dbClient.updateObject(clones);
        }
        _log.error("Failed to create group clone. ", e);
        ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        try {
            if (task == null || isTaskInTerminalState(task.getStatus())) {
                // post process storage pool capacity for clone's pools
                // map clones to their storage pool
                Map<URI, List<URI>> dbPoolToClone = new HashMap<>();
                for (Volume clone : clones) {
                    URI dbPoolUri = clone.getPool();
                    List<URI> poolClones = dbPoolToClone.get(dbPoolUri);
                    if (poolClones == null) {
                        poolClones = new ArrayList<>();
                        dbPoolToClone.put(dbPoolUri, poolClones);
                    }
                    poolClones.add(clone.getId());
                }
                for (URI dbPoolUri : dbPoolToClone.keySet()) {
                    StoragePool dbPool = dbClient.queryObject(StoragePool.class, dbPoolUri);
                    updateStoragePoolCapacity(dbPool, storageSystem, dbPoolToClone.get(dbPoolUri), dbClient);
                }
            }
        } catch (Exception ex) {
            _log.error("Failed to update storage pool after create group clone operation completion.", ex);
        }
    }
}
Also used : VolumeConsistencyGroup(com.emc.storageos.storagedriver.model.VolumeConsistencyGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) DriverTask(com.emc.storageos.storagedriver.DriverTask) CreateGroupCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.CreateGroupCloneExternalDeviceJob) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) HashSet(java.util.HashSet)

Example 29 with QueueJob

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

the class HDSMirrorOperations method deleteSingleVolumeMirror.

/**
 * Deletes mirror instance from StorageSystem
 */
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
        Set<String> thickLogicalUnitIdList = new HashSet<String>();
        Set<String> thinLogicalUnitIdList = new HashSet<String>();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
        String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
        LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
        if (logicalUnit == null) {
            // related volume state (if any) has been deleted. skip
            // processing, if already deleted from array.
            log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
            // HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
            dbClient.markForDeletion(mirrorObj);
        } else {
            if (mirrorObj.getThinlyProvisioned()) {
                thinLogicalUnitIdList.add(logicalUnitObjectId);
            } else {
                thickLogicalUnitIdList.add(logicalUnitObjectId);
            }
            log.info(logMsgBuilder.toString());
            if (!thickLogicalUnitIdList.isEmpty()) {
                String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThickLUsJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
            if (!thinLogicalUnitIdList.isEmpty()) {
                String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThinHDSJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
        }
        log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
    } catch (Exception e) {
        log.error("Problem in deleteSingleVolumeMirror: ", e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : HDSBlockMirrorDeleteJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) HashSet(java.util.HashSet)

Example 30 with QueueJob

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

the class HDSStorageDevice method doDeleteVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes(com.emc.storageos.db.client.model.StorageSystem,
     * java.lang.String, java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
        MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
        Set<String> thickLogicalUnitIdList = new HashSet<String>();
        Set<String> thinLogicalUnitIdList = new HashSet<String>();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
        log.info("volumes size: {}", volumes.size());
        for (Volume volume : volumes) {
            logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
            String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storageSystem);
            LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectId, logicalUnitObjectId);
            if (logicalUnit == null) {
                // related volume state (if any) has been deleted. skip
                // processing, if already deleted from array.
                log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                dbClient.persistObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(dbClient);
                continue;
            }
            if (volume.getThinlyProvisioned()) {
                thinLogicalUnitIdList.add(logicalUnitObjectId);
            } else {
                thickLogicalUnitIdList.add(logicalUnitObjectId);
            }
        }
        log.info(logMsgBuilder.toString());
        if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
            if (null != thickLogicalUnitIdList && !thickLogicalUnitIdList.isEmpty()) {
                String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectId, thickLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThickLUsJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThickLUsJobId, volumes.get(0).getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
                }
            }
            if (null != thinLogicalUnitIdList && !thinLogicalUnitIdList.isEmpty()) {
                String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectId, thinLogicalUnitIdList, storageSystem.getModel());
                // in single operation.
                if (null != asyncThinHDSJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThinHDSJobId, volumes.get(0).getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
                }
            }
        } else {
            // If we are here, there are no volumes to delete, we have
            // invoked ready() for the VolumeDeleteCompleter, and told
            // the multiVolumeTaskCompleter to skip these completers.
            // In this case, the multiVolumeTaskCompleter complete()
            // method will not be invoked and the result is that the
            // workflow that initiated this delete request will never
            // be updated. So, here we just call complete() on the
            // multiVolumeTaskCompleter to ensure the workflow status is
            // updated.
            multiVolumeTaskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error("Problem in doDeleteVolume: ", e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("doDeleteVolume", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) HDSDeleteVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSDeleteVolumeJob) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) MetaVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MetaVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) HashSet(java.util.HashSet)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)109 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)104 Volume (com.emc.storageos.db.client.model.Volume)51 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 CIMObjectPath (javax.cim.CIMObjectPath)41 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)40 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)40 VNXeException (com.emc.storageos.vnxe.VNXeException)36 WBEMException (javax.wbem.WBEMException)33 ControllerException (com.emc.storageos.volumecontroller.ControllerException)32 CIMArgument (javax.cim.CIMArgument)32 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)25 URI (java.net.URI)24 ArrayList (java.util.ArrayList)23 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)20 Snapshot (com.emc.storageos.db.client.model.Snapshot)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileShare (com.emc.storageos.db.client.model.FileShare)16