Search in sources :

Example 1 with MultiCopyEnableImageRequestParams

use of com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams 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 MultiCopyEnableImageRequestParams

use of com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams in project coprhd-controller by CoprHD.

the class RPDeviceController method enableImageAccessForCreateReplicaStep.

/**
 * Enable image access before create native array replica operation
 *
 * @param protectionDevice
 * @param clazz
 *            type of replica (such as Volume, BlockSnapshot or BlockSnapshotSession)
 * @param copyList
 *            list of replica ids
 * @param bookmarkName
 *            name of the bookmark created for this operation
 * @param volumeWWNs
 *            wwns of volumes that are parents to replica objects
 * @param opId
 * @return
 * @throws ControllerException
 */
public boolean enableImageAccessForCreateReplicaStep(URI protectionDevice, Class<? extends DataObject> clazz, List<URI> copyList, String bookmarkName, Set<String> volumeWWNs, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        _log.info(String.format("Activating bookmark %s on the RP CG(s)", bookmarkName));
        completer = new RPCGCopyVolumeCompleter(clazz, copyList, opId);
        // Verify non-null storage device returned from the database client.
        ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
        if (system == null || system.getInactive()) {
            throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
        }
        // enable image access to that bookmark
        RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
        MultiCopyEnableImageRequestParams request = new MultiCopyEnableImageRequestParams();
        request.setVolumeWWNSet(volumeWWNs);
        request.setBookmark(bookmarkName);
        MultiCopyEnableImageResponse response = rp.enableImageCopies(request);
        if (response == null) {
            throw DeviceControllerExceptions.recoverpoint.failedEnableAccessOnRP();
        }
        completer.ready(_dbClient);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(opId);
        return true;
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        stepFailed(opId, "enableImageAccessStep: Failed to enable image");
        return false;
    } catch (Exception e) {
        _log.error("Operation failed with Exception: ", e);
        if (completer != null) {
            completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
        }
        stepFailed(opId, "enableImageAccessStep: Failed to enable image");
        return false;
    }
}
Also used : RPCGCopyVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGCopyVolumeCompleter) MultiCopyEnableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) 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) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) MultiCopyEnableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams) 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)

Example 3 with MultiCopyEnableImageRequestParams

use of com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method testEnableDisableRPBookmarks.

// @Test
public void testEnableDisableRPBookmarks() throws InterruptedException {
    boolean foundError = false;
    logger.info("Testing RecoverPoint Enable/Disable Bookmark");
    MultiCopyEnableImageRequestParams enableParams = new MultiCopyEnableImageRequestParams();
    MultiCopyDisableImageRequestParams disableParams = new MultiCopyDisableImageRequestParams();
    try {
        recreateCGAndBookmark();
        enableParams.setBookmark(Bookmarkname);
        Set<String> WWNSetForTest = new HashSet<String>();
        WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
        WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
        enableParams.setVolumeWWNSet(WWNSetForTest);
        disableParams.setVolumeWWNSet(WWNSetForTest);
        disableParams.setEmName(Bookmarkname);
        rpClient.enableImageCopies(enableParams);
        logger.info("Sleep 15 seconds before disable of image");
        Thread.sleep(15000);
        rpClient.disableImageCopies(disableParams);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (!foundError) {
        logger.info("TestEnableDisableRPBookmarks PASSED");
    }
}
Also used : RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) MultiCopyDisableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams) MultiCopyEnableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams) HashSet(java.util.HashSet)

Example 4 with MultiCopyEnableImageRequestParams

use of com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method testExceptionUseCases.

// @Test
public void testExceptionUseCases() throws InterruptedException {
    boolean foundError = false;
    logger.info("Testing RecoverPoint Exception Use Cases");
    try {
        // RecreateCGAndBookmark();
        logger.info("Pause Pause Resume on a CG Copy");
        RecoverPointVolumeProtectionInfo protectionInfo = null;
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
        rpClient.pauseTransfer(protectionInfo);
        rpClient.pauseTransfer(protectionInfo);
        rpClient.resumeTransfer(protectionInfo);
        logger.info("Pause Pause Resume on a CG Copy PASSED");
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    try {
        logger.info("Disable Disable Enable on a CG Copy");
        RecoverPointVolumeProtectionInfo protectionInfo = null;
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
        rpClient.disableProtection(protectionInfo);
        rpClient.disableProtection(protectionInfo);
        rpClient.enableProtection(protectionInfo);
        logger.info("Disable Disable Enable on a CG Copy PASSED");
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    try {
        logger.info("Enable Most Recent Image, Enable Bookmark (should fail)");
        CreateBookmarkRequestParams params = new CreateBookmarkRequestParams();
        Bookmarkname = "BourneBookmark_";
        Random randomnumber = new Random();
        Bookmarkname += Math.abs(randomnumber.nextInt());
        params.setBookmark(Bookmarkname);
        Set<String> WWNSetToBookmark = new HashSet<String>();
        WWNSetToBookmark.add(BourneRPTestCRRLUN1WWN);
        WWNSetToBookmark.add(BourneRPTestCRRLUN2WWN);
        params.setVolumeWWNSet(WWNSetToBookmark);
        rpClient.createBookmarks(params);
        MultiCopyEnableImageRequestParams enableParams = new MultiCopyEnableImageRequestParams();
        MultiCopyEnableImageRequestParams enableParams1 = new MultiCopyEnableImageRequestParams();
        MultiCopyDisableImageRequestParams disableParams = new MultiCopyDisableImageRequestParams();
        Set<String> WWNSetForTest = new HashSet<String>();
        WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
        WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
        enableParams.setVolumeWWNSet(WWNSetForTest);
        enableParams1.setVolumeWWNSet(WWNSetForTest);
        disableParams.setVolumeWWNSet(WWNSetForTest);
        disableParams.setEmName(Bookmarkname);
        rpClient.enableImageCopies(enableParams1);
        try {
            rpClient.enableImageCopies(enableParams);
            foundError = true;
        } catch (RecoverPointException e) {
            logger.info("Enable Most Recent Image, Enable Bookmark PASSED");
        }
        logger.info("Sleep 15 seconds before disable of image");
        Thread.sleep(15000);
        rpClient.disableImageCopies(disableParams);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (!foundError) {
        logger.info("TestExceptionUseCases PASSED");
    } else {
        fail("TestExceptionUseCases FAILED");
    }
}
Also used : CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Random(java.util.Random) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) MultiCopyDisableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams) MultiCopyEnableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams) HashSet(java.util.HashSet)

Aggregations

RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)4 MultiCopyEnableImageRequestParams (com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams)4 HashSet (java.util.HashSet)3 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 LockRetryException (com.emc.storageos.locking.LockRetryException)2 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)2 MultiCopyDisableImageRequestParams (com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams)2 MultiCopyEnableImageResponse (com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 RPCGProtectionTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter)2 VolumeVpoolChangeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVpoolChangeTaskCompleter)2 VolumeGroupUpdateTaskCompleter (com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter)2