Search in sources :

Example 11 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method failoverCopyCancel.

/**
 * Cancel a failover operation, usually a failover after a failover without a swap.
 *
 * @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG that a previous failover test was performed on
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void failoverCopyCancel(RPCopyRequestParams copyToFailoverTo) throws RecoverPointException {
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    imageManager.disableCopyImage(functionalAPI, copyToFailoverTo);
}
Also used : RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)

Example 12 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method getCopyAccessStates.

/**
 * Checks to see if the given copy is in direct access state.
 *
 * @param copyToExamine the copy to check for direct access state
 * @return true if the given copy is in direct access state, false otherwise
 */
public Map<String, String> getCopyAccessStates(Set<String> rpWWNs) {
    Map<String, String> copyAccessStates = new HashMap<String, String>();
    if (rpWWNs != null) {
        for (String wwn : rpWWNs) {
            RecoverPointVolumeProtectionInfo protectionInfo = getProtectionInfoForVolume(wwn);
            ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(protectionInfo);
            if (cgCopyUID != null) {
                RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
                ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
                if (copyState != null) {
                    StorageAccessState copyAccessState = copyState.getStorageAccessState();
                    copyAccessStates.put(wwn, copyAccessState.name());
                }
            }
        }
    }
    logger.info(String.format("Access states for requested copies: %s", copyAccessStates));
    return copyAccessStates;
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) HashMap(java.util.HashMap) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 13 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method setCopyAsProduction.

/**
 * Prepares the copy link settings and sets copy as production. This would typically be
 * called following a call to swapCopy.
 *
 * @param copyParams the volume info for preparing the CG links and setting copy as production.
 * @throws RecoverPointException
 */
public void setCopyAsProduction(RPCopyRequestParams copyParams) throws RecoverPointException {
    logger.info(String.format("Setting copy %s as production copy.", (copyParams.getCopyVolumeInfo() != null) ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A"));
    // Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
    // Prepare the link settings for new links
    prepareLinkSettings(cgCopyUID);
    // Set the failover copy as production to resume data flow
    imageManager.setCopyAsProduction(functionalAPI, cgCopyUID);
    // wait for links to become active
    ConsistencyGroupUID cgUID = cgCopyUID.getGroupUID();
    String cgName = null;
    try {
        cgName = functionalAPI.getGroupName(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        // benign error -- cgName is only used for logging
        logger.error(e.getMessage(), e);
    }
    boolean waitForLinkStates = false;
    // In a true DR scenario, we cant expect links to become active and that should not fail the swap/failover operation.
    if (waitForLinkStates) {
        logger.info("Waiting for links to become active for CG " + (cgName == null ? "unknown CG name" : cgName));
        (new RecoverPointImageManagementUtils()).waitForCGLinkState(functionalAPI, cgUID, PipeState.ACTIVE);
    } else {
        logger.info("Not waiting for links to become active for CG" + (cgName == null ? "unknown CG name" : cgName));
    }
    logger.info(String.format("Replication sets have been added to consistency group %s.", (cgName == null ? "unknown CG name" : cgName)));
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 14 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method restoreImageCopies.

/**
 * Restore copy images for one or more consistency group copies
 *
 * @param MultiCopyRestoreImageRequestParams request - contains the information about which CG copies to restore
 *
 * @return MultiCopyRestoreImageResponse - response as to success or fail of restoring the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyRestoreImageResponse restoreImageCopies(MultiCopyRestoreImageRequestParams request) throws RecoverPointException {
    MultiCopyRestoreImageResponse response = new MultiCopyRestoreImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setBookmark(request.getBookmark());
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        // logger.info("Get RPCG for volume: " + volume);
        cgSetToEnable.add(rpCGMap.get(volume));
    }
    ClusterUID siteToRestore = null;
    // Verify that we are not restoring from different sites
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            if (siteToRestore == null) {
                siteToRestore = copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID();
            } else if (siteToRestore.getId() != copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID().getId()) {
                throw RecoverPointException.exceptions.cannotRestoreVolumesFromDifferentSites(wwnSet);
            }
            try {
                List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(copy.getCGGroupCopyUID().getGroupUID()).getProductionCopiesUIDs();
                for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
                    if (RecoverPointUtils.copiesEqual(productionCopyUID, copy.getCGGroupCopyUID())) {
                        throw RecoverPointException.exceptions.cannotRestoreVolumesInConsistencyGroup(wwnSet);
                    }
                }
            } catch (FunctionalAPIActionFailedException_Exception e) {
                logger.error(e.getMessage());
                logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
                throw RecoverPointException.exceptions.failureRestoringVolumes();
            } catch (FunctionalAPIInternalError_Exception e) {
                logger.error(e.getMessage());
                logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
                throw RecoverPointException.exceptions.failureRestoringVolumes();
            }
        }
    }
    try {
        for (RPConsistencyGroup rpcg : cgSetToEnable) {
            Set<RPCopy> copies = rpcg.getCopies();
            for (RPCopy copy : copies) {
                boolean waitForLinkState = false;
                imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
            }
        }
    } catch (RecoverPointException e) {
        logger.error("Caught exception while enabling CG copies for restore.  Return copies to previous state");
        for (RPConsistencyGroup rpcg : cgSetToEnable) {
            Set<RPCopy> copies = rpcg.getCopies();
            for (RPCopy copy : copies) {
                imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
            }
        }
        throw e;
    }
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            imageManager.restoreEnabledCGCopy(functionalAPI, copy.getCGGroupCopyUID());
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet) HashSet(java.util.HashSet) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) ClusterUID(com.emc.fapiclient.ws.ClusterUID) MultiCopyRestoreImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyRestoreImageResponse) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) HashSet(java.util.HashSet)

Example 15 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method failoverCopyTestCancel.

/**
 * Cancel a failover test for a consistency group copy specified by the input request params.
 *
 * @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG that a previous failover test was performed on
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void failoverCopyTestCancel(RPCopyRequestParams copyToFailoverTo) throws RecoverPointException {
    RecoverPointVolumeProtectionInfo failoverCopyInfo = copyToFailoverTo.getCopyVolumeInfo();
    resumeTransfer(failoverCopyInfo);
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    imageManager.disableCopyImage(functionalAPI, copyToFailoverTo);
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)

Aggregations

RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)17 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)10 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)10 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)7 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)3 RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)3 RPCopy (com.emc.storageos.recoverpoint.objectmodel.RPCopy)3 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)3 RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)3 RecoverPointBookmarkManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 RecoverPointCGResponse (com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse)2