Search in sources :

Example 21 with ConsistencyGroupCopyUID

use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.

the class RecoverPointClient method getCGCopyUid.

/**
 * construct a CG copy UID
 *
 * @param clusterUID
 * @param copyType
 * @param cgUID
 * @return
 */
private ConsistencyGroupCopyUID getCGCopyUid(ClusterUID clusterUID, RecoverPointCGCopyType copyType, ConsistencyGroupUID cgUID) {
    ConsistencyGroupCopyUID cgCopyUID = new ConsistencyGroupCopyUID();
    GlobalCopyUID globalCopyUID = new GlobalCopyUID();
    globalCopyUID.setClusterUID(clusterUID);
    globalCopyUID.setCopyUID(copyType.getCopyNumber());
    cgCopyUID.setGlobalCopyUID(globalCopyUID);
    cgCopyUID.setGroupUID(cgUID);
    return cgCopyUID;
}
Also used : GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 22 with ConsistencyGroupCopyUID

use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.

the class RecoverPointClient method findLinkSettings.

/**
 * Find the link settings corresponding to the given production and target copy identifiers.
 *
 * @param linkSettings the consistency group link settings
 * @param prodCopyUID the production copy
 * @param targetCopyUID the target copy
 * @param prodCopyName the name of the production copy
 * @param targetCopyName the name of the target copy
 * @return the consistency group settings matching the prod/target copy relationship
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private ConsistencyGroupLinkSettings findLinkSettings(List<ConsistencyGroupLinkSettings> cgLinkSettings, GlobalCopyUID prodCopyUID, GlobalCopyUID targetCopyUID, String prodCopyName, String targetCopyName) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    ConsistencyGroupLinkSettings toRet = null;
    if (cgLinkSettings != null && !cgLinkSettings.isEmpty() && prodCopyUID != null && targetCopyUID != null) {
        for (ConsistencyGroupLinkSettings linkSetting : cgLinkSettings) {
            ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
            firstCopyUID.setGlobalCopyUID(linkSetting.getGroupLinkUID().getFirstCopy());
            firstCopyUID.setGroupUID(linkSetting.getGroupLinkUID().getGroupUID());
            ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
            secondCopyUID.setGlobalCopyUID(linkSetting.getGroupLinkUID().getSecondCopy());
            secondCopyUID.setGroupUID(linkSetting.getGroupLinkUID().getGroupUID());
            String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
            String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
            logger.info(String.format("Examining existing link settings between %s and %s.  Attempting to find a link between %s and %s.", firstCopyName, secondCopyName, prodCopyName, targetCopyName));
            if (isMatchingLinkSettings(linkSetting, prodCopyUID, targetCopyUID)) {
                logger.info("Found existing link settings between {} and {}.", prodCopyName, targetCopyName);
                toRet = linkSetting;
                break;
            }
        }
    }
    if (toRet == null) {
        logger.info("Unable to find existing link settings between {} and {}.", prodCopyName, targetCopyName);
    }
    return toRet;
}
Also used : ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 23 with ConsistencyGroupCopyUID

use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID 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 24 with ConsistencyGroupCopyUID

use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID 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 25 with ConsistencyGroupCopyUID

use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID 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)

Aggregations

ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)34 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)24 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)24 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)14 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)9 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)9 ClusterUID (com.emc.fapiclient.ws.ClusterUID)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 HashMap (java.util.HashMap)6 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)5 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)4 HashSet (java.util.HashSet)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)3