Search in sources :

Example 1 with BlockSnapshotActivateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotActivateCompleter in project coprhd-controller by CoprHD.

the class RPDeviceController method enableImageForSnapshots.

/**
 * Enable image access for RP snapshots.
 *
 * @param protectionDevice
 *            protection system
 * @param storageDevice
 *            storage device of the backing (parent) volume
 * @param snapshotList
 *            list of snapshots to enable
 * @param opId
 *            task ID
 * @return true if operation was successful
 * @throws ControllerException
 * @throws URISyntaxException
 */
private boolean enableImageForSnapshots(URI protectionDevice, URI storageDevice, List<URI> snapshotList, String opId) throws ControllerException, URISyntaxException {
    TaskCompleter completer = null;
    try {
        _log.info("Activating a bookmark on the RP CG(s)");
        completer = new BlockSnapshotActivateCompleter(snapshotList, opId);
        ProtectionSystem system = null;
        try {
            system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
        } catch (DatabaseException e) {
            throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
        }
        // Verify non-null storage device returned from the database client.
        if (system == null) {
            throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
        }
        // is still creating the snapshot
        if (snapshotList != null && !snapshotList.isEmpty()) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
            Volume parent = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
            final List<Volume> vplexVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Volume.class, getVolumesByAssociatedId(parent.getId().toString()));
            if (vplexVolumes != null && !vplexVolumes.isEmpty()) {
                parent = vplexVolumes.get(0);
            }
            String lockName = ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, parent.getConsistencyGroup(), system.getId());
            if (null != lockName) {
                List<String> locks = new ArrayList<String>();
                locks.add(lockName);
                acquireWorkflowLockOrThrow(_workflowService.getWorkflowFromStepId(opId), locks);
            }
        }
        // Keep a mapping of the emNames(bookmark names) to target copy volume WWNs
        Map<String, Set<String>> emNamesToVolumeWWNs = new HashMap<String, Set<String>>();
        // Keep a mapping of the emNames(bookmark names) to BlockSnapshot objects
        Map<String, Set<URI>> emNamesToSnapshots = new HashMap<String, Set<URI>>();
        for (URI snapshotID : snapshotList) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
            String emName = snapshot.getEmName();
            if (NullColumnValueGetter.isNotNullValue(emName)) {
                if (!emNamesToVolumeWWNs.containsKey(emName)) {
                    emNamesToVolumeWWNs.put(emName, new HashSet<String>());
                }
                if (!emNamesToSnapshots.containsKey(emName)) {
                    emNamesToSnapshots.put(emName, new HashSet<URI>());
                }
                emNamesToSnapshots.get(emName).add(snapshotID);
            } else {
                throw DeviceControllerExceptions.recoverpoint.failedToActivateSnapshotEmNameMissing(snapshotID);
            }
            // Get the volume associated with this snapshot
            Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
            // Fetch the VPLEX volume that is created with this volume as the back-end volume.
            if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
                volume = Volume.fetchVplexVolume(_dbClient, volume);
            }
            String wwn = null;
            // If the personality is SOURCE, then the enable image access request is part of export operation.
            if (volume.checkPersonality(Volume.PersonalityTypes.TARGET.toString())) {
                wwn = RPHelper.getRPWWn(volume.getId(), _dbClient);
            } else {
                // Now determine the target volume that corresponds to the site of the snapshot
                ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
                Volume targetVolume = ProtectionSet.getTargetVolumeFromSourceAndInternalSiteName(_dbClient, protectionSet, volume, snapshot.getEmInternalSiteName());
                wwn = RPHelper.getRPWWn(targetVolume.getId(), _dbClient);
            }
            // Add the volume WWN
            emNamesToVolumeWWNs.get(emName).add(wwn);
        }
        // Now enable image access to that bookmark
        RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
        // correponding to each emName.
        for (Map.Entry<String, Set<String>> emNameEntry : emNamesToVolumeWWNs.entrySet()) {
            MultiCopyEnableImageRequestParams request = new MultiCopyEnableImageRequestParams();
            request.setVolumeWWNSet(emNameEntry.getValue());
            request.setBookmark(emNameEntry.getKey());
            MultiCopyEnableImageResponse response = rp.enableImageCopies(request);
            if (response == null) {
                throw DeviceControllerExceptions.recoverpoint.failedEnableAccessOnRP();
            }
        }
        completer.ready(_dbClient);
        return true;
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        throw e;
    } catch (URISyntaxException e) {
        _log.error("Operation failed with Exception: ", e);
        if (completer != null) {
            completer.error(_dbClient, DeviceControllerException.errors.invalidURI(e));
        }
        throw e;
    } catch (Exception e) {
        _log.error("Operation failed with Exception: ", e);
        if (completer != null) {
            completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
        }
        throw e;
    }
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) MultiCopyEnableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) URISyntaxException(java.net.URISyntaxException) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) VolumeVpoolChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVpoolChangeTaskCompleter) RPCGProtectionTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) BlockSnapshotActivateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotActivateCompleter) MultiCopyEnableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams)

Example 2 with BlockSnapshotActivateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotActivateCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method activateSnapshot.

@Override
public void activateSnapshot(URI storage, List<URI> snapshotList, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        completer = new BlockSnapshotActivateCompleter(snapshotList, opId);
        getDevice(storageObj.getSystemType()).doActivateSnapshot(storageObj, snapshotList, completer);
    } catch (Exception e) {
        if (completer != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            completer.error(_dbClient, serviceError);
        } else {
            throw DeviceControllerException.exceptions.activateVolumeSnapshotFailed(e);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) BlockSnapshotActivateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotActivateCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 BlockSnapshotActivateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotActivateCompleter)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)1 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)1 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 Volume (com.emc.storageos.db.client.model.Volume)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1