Search in sources :

Example 26 with RecoverPointClient

use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.

the class RPDeviceController method getCopyAccessStates.

@Override
public Map<URI, String> getCopyAccessStates(URI protectionSystemURI, List<URI> volumeURIs) {
    _log.info(String.format("Finding RecoverPoint copy states for volumes %s", volumeURIs));
    Map<URI, String> copyAccessStates = new HashMap<URI, String>();
    if (protectionSystemURI != null && volumeURIs != null) {
        // Validate that all volumeURIs share the same protection system that is passed in.
        // Also, create a WWN to volume URI map so we can tie the WWN volume access state back
        // to the ViPR volume URI.
        Map<String, URI> wwnToVolumeUri = new HashMap<String, URI>();
        for (URI volumeURI : volumeURIs) {
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            if (!protectionSystemURI.equals(volume.getProtectionController())) {
                throw DeviceControllerExceptions.recoverpoint.failedToGetCopyAccessStateProtectionSystemMismatch(volume.getId(), protectionSystemURI);
            }
            String wwn = RPHelper.getRPWWn(volumeURI, _dbClient);
            wwnToVolumeUri.put(wwn, volumeURI);
        }
        ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, protectionSystemURI);
        RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
        Map<String, String> wwnToAccessState = rp.getCopyAccessStates(wwnToVolumeUri.keySet());
        for (Map.Entry<String, String> wwnEntry : wwnToAccessState.entrySet()) {
            copyAccessStates.put(wwnToVolumeUri.get(wwnEntry.getKey()), wwnEntry.getValue());
        }
    }
    _log.info(String.format("Found the following RecoverPoint copy states %s", copyAccessStates));
    return copyAccessStates;
}
Also used : HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap)

Example 27 with RecoverPointClient

use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.

the class RPDeviceController method updateConsistencyGroupPolicyStep.

/**
 * Updates the consistency group policy (replication mode).
 *
 * @param protectionSystem
 *            the RP protection system
 * @param cgUri
 *            the consistency group ID
 * @param copyMode
 *            the copy/replication mode (sync or async)
 * @param stepId
 *            the step ID
 * @return true if the step executes successfully, false otherwise.
 */
public boolean updateConsistencyGroupPolicyStep(ProtectionSystem protectionSystem, URI cgUri, String copyMode, String stepId) {
    try {
        _log.info(String.format("Updating consistency group policy for CG %s.", cgUri));
        WorkflowStepCompleter.stepExecuting(stepId);
        RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
        // lock around update policy operations on the same CG
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgUri, protectionSystem.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Upgrade policy for RP consistency group %s; id: %s", cg.getLabel(), cgUri.toString()));
        }
        CGPolicyParams policyParams = new CGPolicyParams(copyMode);
        UpdateCGPolicyParams updateParams = new UpdateCGPolicyParams(cg.getCgNameOnStorageSystem(protectionSystem.getId()), policyParams);
        rp.updateConsistencyGroupPolicy(updateParams);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, (ServiceCoded) e, "updateConsistencyGroupPolicyStep");
    } catch (Exception e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, e, "updateConsistencyGroupPolicyStep");
    }
    return true;
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) ArrayList(java.util.ArrayList) UpdateCGPolicyParams(com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) UpdateCGPolicyParams(com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams) CGPolicyParams(com.emc.storageos.recoverpoint.requests.CGPolicyParams) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 28 with RecoverPointClient

use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.

the class RPDeviceController method getReplicationSettings.

/**
 * Gets the replication settings from RP for a given volume.
 *
 * @param rpSystem
 *            the RecoverPoint system.
 * @param volumeId
 *            the volume ID.
 * @return the replication set params to perform a recreate operation
 * @throws RecoverPointException
 */
public RecreateReplicationSetRequestParams getReplicationSettings(ProtectionSystem rpSystem, URI volumeId) throws RecoverPointException {
    RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
    Volume volume = _dbClient.queryObject(Volume.class, volumeId);
    RecoverPointVolumeProtectionInfo volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(volume.getId(), _dbClient));
    return rp.getReplicationSet(volumeProtectionInfo);
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient)

Example 29 with RecoverPointClient

use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.

the class RPDeviceController method searchForBookmarks.

/**
 * Searches for all specified bookmarks (RP snapshots). If even just one
 * bookmark does not exist, an exception will be thrown.
 *
 * @param protectionDevice
 *            the protection system URI
 * @param snapshots
 *            the RP snapshots to search for
 */
private void searchForBookmarks(URI protectionDevice, Set<URI> snapshots) {
    ProtectionSystem rpSystem = getRPSystem(protectionDevice);
    RecoverPointClient rpClient = RPHelper.getRecoverPointClient(rpSystem);
    // Check that the bookmarks actually exist
    Set<Integer> cgIDs = null;
    boolean bookmarkExists;
    // Map used to keep track of which BlockSnapshots map to which CGs
    Map<Integer, List<BlockSnapshot>> cgSnaps = new HashMap<Integer, List<BlockSnapshot>>();
    for (URI snapshotID : snapshots) {
        cgIDs = new HashSet<Integer>();
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
        // Get the volume associated with this snapshot
        Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
        // Now get the protection set (CG) associated with the volume so we can use
        // it to search for the bookmark
        ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
        Integer cgID = null;
        try {
            cgID = Integer.valueOf(protectionSet.getProtectionId());
        } catch (NumberFormatException nfe) {
            throw DeviceControllerExceptions.recoverpoint.exceptionLookingForBookmarks(nfe);
        }
        cgIDs.add(cgID);
        if (cgSnaps.get(cgID) == null) {
            cgSnaps.put(cgID, new ArrayList<BlockSnapshot>());
        }
        cgSnaps.get(cgID).add(snapshot);
    }
    GetBookmarksResponse bookmarkResponse = rpClient.getRPBookmarks(cgIDs);
    // one exists in RP. Fail if any of the snapshots does not exist.
    for (Integer cgID : cgSnaps.keySet()) {
        for (BlockSnapshot snapshot : cgSnaps.get(cgID)) {
            bookmarkExists = false;
            if (bookmarkResponse.getCgBookmarkMap() != null && !bookmarkResponse.getCgBookmarkMap().isEmpty()) {
                List<RPBookmark> rpBookmarks = bookmarkResponse.getCgBookmarkMap().get(cgID);
                if (rpBookmarks != null && !rpBookmarks.isEmpty()) {
                    // Find the bookmark
                    for (RPBookmark rpBookmark : rpBookmarks) {
                        if (rpBookmark.getBookmarkName().equals(snapshot.getEmName())) {
                            bookmarkExists = true;
                        }
                    }
                }
            }
            if (!bookmarkExists) {
                throw DeviceControllerExceptions.recoverpoint.failedToFindExpectedBookmarks();
            }
        }
    }
}
Also used : GetBookmarksResponse(com.emc.storageos.recoverpoint.responses.GetBookmarksResponse) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) RPBookmark(com.emc.storageos.recoverpoint.objectmodel.RPBookmark)

Example 30 with RecoverPointClient

use of com.emc.storageos.recoverpoint.impl.RecoverPointClient 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

RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)31 ArrayList (java.util.ArrayList)18 URI (java.net.URI)17 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)15 Volume (com.emc.storageos.db.client.model.Volume)15 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)15 URISyntaxException (java.net.URISyntaxException)15 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)13 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)13 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)13 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 LockRetryException (com.emc.storageos.locking.LockRetryException)13 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)13 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 WorkflowException (com.emc.storageos.workflow.WorkflowException)13 NamedURI (com.emc.storageos.db.client.model.NamedURI)12 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)10 StringSet (com.emc.storageos.db.client.model.StringSet)7