Search in sources :

Example 1 with QueueJob

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

the class ExternalBlockStorageDevice method doRestoreFromGroupClone.

@Override
public void doRestoreFromGroupClone(StorageSystem storageSystem, List<URI> cloneVolumes, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    DriverTask task = null;
    List<Volume> clones = dbClient.queryObject(Volume.class, cloneVolumes);
    _log.info("Restore from group clone on storage system {}, clones: {} .", storageSystem.getNativeId(), clones.toString());
    try {
        Map<VolumeClone, Volume> driverCloneToCloneMap = new HashMap<>();
        List<VolumeClone> driverClones = new ArrayList<>();
        for (Volume clone : clones) {
            BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
            VolumeClone driverClone = new VolumeClone();
            driverClone.setStorageSystemId(storageSystem.getNativeId());
            driverClone.setNativeId(clone.getNativeId());
            driverClone.setParentId(sourceVolume.getNativeId());
            driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
            driverClones.add(driverClone);
            driverCloneToCloneMap.put(driverClone, clone);
        }
        // Call driver
        task = driver.restoreFromClone(Collections.unmodifiableList(driverClones));
        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 replica state and call the completer as appropriate based on the result
            // of the request.
            RestoreFromGroupCloneExternalDeviceJob job = new RestoreFromGroupCloneExternalDeviceJob(storageSystem.getId(), cloneVolumes, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            for (Map.Entry<VolumeClone, Volume> entry : driverCloneToCloneMap.entrySet()) {
                VolumeClone driverClone = entry.getKey();
                Volume clone = entry.getValue();
                ExternalDeviceUtils.updateRestoredClone(clone, driverClone, dbClient, false);
            }
            String msg = String.format("doRestoreFromGroupClone -- Restore from group clone: %s .", task.getMessage());
            _log.info(msg);
            dbClient.updateObject(clones);
            taskCompleter.ready(dbClient);
        } else {
            String msg = String.format("Failed to restore from group clone on storage system %s, clones: %s .", storageSystem.getNativeId(), clones.toString());
            _log.error(msg);
            ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromGroupClone", msg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        String msg = String.format("Failed to restore from group clone on storage system %s, clones: %s .", storageSystem.getNativeId(), clones.toString());
        _log.error(msg, e);
        ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromGroupClone", msg);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RestoreFromGroupCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.RestoreFromGroupCloneExternalDeviceJob) 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) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject)

Example 2 with QueueJob

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

the class HDSCloneOperations method restoreFromSingleClone.

@Override
public void restoreFromSingleClone(StorageSystem storageSystem, URI cloneURI, TaskCompleter taskCompleter) {
    try {
        Volume cloneVolume = dbClient.queryObject(Volume.class, cloneURI);
        Volume sourceVolume = dbClient.queryObject(Volume.class, cloneVolume.getAssociatedSourceVolume());
        hdsProtectionOperations.modifyShadowImagePair(storageSystem, sourceVolume.getNativeId(), cloneVolume.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.restore);
        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageSystem.getId(), sourceVolume.getNativeId(), cloneVolume.getNativeId(), ReplicationStatus.PAIR, taskCompleter)));
        log.info("FINISH restoreFromSingleClone for {}", cloneURI);
    } catch (Exception e) {
        String errorMsg = String.format(RESTORE_ERROR_MSG_FORMAT, cloneURI);
        log.error(errorMsg, e);
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
    }
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 3 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 4 with QueueJob

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

the class HDSStorageDevice method doModifyVolumes.

@Override
public void doModifyVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Modify Volume Start - Array:%s, Pool:%s", storage.getSerialNumber(), storagePool.getNativeGuid()));
    String systemObjectID = HDSUtils.getSystemObjectID(storage);
    for (Volume volume : volumes) {
        try {
            HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
            logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s, tieringPolicy: %s", volume.getLabel(), volume.getThinlyProvisioned(), volume.getAutoTieringPolicyUri()));
            LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage));
            String policyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
            String autoTierPolicyName = null;
            if (policyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            } else {
                autoTierPolicyName = HitachiTieringPolicy.getPolicy(policyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
            }
            if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
                if (ldevItr.hasNext()) {
                    LDEV ldev = ldevItr.next();
                    String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, logicalUnit.getObjectID(), ldev.getObjectID(), autoTierPolicyName, storage.getModel());
                    if (null != asyncMessageId) {
                        HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_MODIFY_JOB);
                        ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
                    } else {
                        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
                    }
                }
            } else {
                String errorMsg = String.format("No LDEV's found for volume: %s", volume.getId());
                log.info(errorMsg);
                ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", errorMsg);
                taskCompleter.error(dbClient, serviceError);
            }
        } catch (final Exception e) {
            log.error("Problem in doModifyVolumes: ", e);
            ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", e.getMessage());
            taskCompleter.error(dbClient, serviceError);
        }
    }
}
Also used : HDSModifyVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) 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)

Example 5 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)23 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