Search in sources :

Example 1 with MultiCopyRestoreImageRequestParams

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

the class RecoverPointClientIntegrationTest method testRestoreRPBookmarks.

@Test
public void testRestoreRPBookmarks() throws InterruptedException {
    boolean foundError = false;
    logger.info("Testing RecoverPoint Create Bookmark");
    MultiCopyRestoreImageRequestParams restoreParams = new MultiCopyRestoreImageRequestParams();
    try {
        recreateCGAndBookmark();
        restoreParams.setBookmark(Bookmarkname);
        Set<String> WWNSetForTest = new HashSet<String>();
        WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
        WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
        restoreParams.setVolumeWWNSet(WWNSetForTest);
        restoreParams.setVolumeWWNSet(WWNSetForTest);
        rpClient.restoreImageCopies(restoreParams);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (!foundError) {
        logger.info("TestRestoreRPBookmarks PASSED");
    }
}
Also used : RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) MultiCopyRestoreImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyRestoreImageRequestParams) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with MultiCopyRestoreImageRequestParams

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

the class RPDeviceController method restoreVolume.

/**
 * Restore an RP bookmark. This will enable the specified bookmark on the CG if the CG is not already enabled. This
 * step is
 * required for RP bookmark restores.
 *
 * @param protectionDevice
 *            RP protection system URI
 * @param storageDevice
 *            storage device of the volume
 * @param snapshotId
 *            snapshot URI
 * @param task
 *            task ID
 * @return true if the step completed successfully, false otherwise.
 * @throws InternalException
 */
public boolean restoreVolume(URI protectionDevice, URI storageDevice, URI snapshotID, BlockSnapshotRestoreCompleter completer, String stepId) throws InternalException {
    try {
        _log.info("Restoring bookmark on the RP CG");
        WorkflowStepCompleter.stepExecuting(stepId);
        ProtectionSystem system = null;
        system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
        if (system == null) {
            // Verify non-null storage device returned from the database client.
            throw DeviceControllerExceptions.recoverpoint.failedConnectingForMonitoring(protectionDevice);
        }
        Set<String> volumeWWNs = new HashSet<String>();
        String emName = null;
        // Get the volume associated with this snapshot
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
        if (snapshot.getEmName() != null) {
            emName = snapshot.getEmName();
        }
        Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
        // Take out a workflow step lock on the CG
        _workflowService.getWorkflowFromStepId(stepId);
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, volume.getConsistencyGroup(), system.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("failed to get lock while restoring volumes in RP consistency group: %s", volume.getConsistencyGroup().toString()));
        }
        // 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());
        volumeWWNs.add(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
        // Now restore image access
        RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
        MultiCopyRestoreImageRequestParams request = new MultiCopyRestoreImageRequestParams();
        request.setBookmark(emName);
        request.setVolumeWWNSet(volumeWWNs);
        MultiCopyRestoreImageResponse response = rp.restoreImageCopies(request);
        if (response == null) {
            throw DeviceControllerExceptions.recoverpoint.failedToImageAccessBookmark();
        }
        WorkflowStepCompleter.stepSucceded(stepId);
        _log.info("restoreVolume step is complete");
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, (ServiceCoded) e, "restoreVolumeStep");
    } catch (URISyntaxException e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, e, "restoreVolumeStep");
    } catch (Exception e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, e, "restoreVolumeStep");
    }
    return true;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) MultiCopyRestoreImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyRestoreImageRequestParams) URISyntaxException(java.net.URISyntaxException) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) 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) MultiCopyRestoreImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyRestoreImageResponse) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) HashSet(java.util.HashSet)

Aggregations

RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)2 MultiCopyRestoreImageRequestParams (com.emc.storageos.recoverpoint.requests.MultiCopyRestoreImageRequestParams)2 HashSet (java.util.HashSet)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 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)1 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)1 MultiCopyRestoreImageResponse (com.emc.storageos.recoverpoint.responses.MultiCopyRestoreImageResponse)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1