Search in sources :

Example 1 with GlobalCopyUID

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

the class RecoverPointClient method prepareLinkSettings.

/**
 * Prepares the link settings between the new production copy and all other copies.
 *
 * @param newProductionCopyUID the failover/new production copy
 * @throws RecoverPointException
 */
private void prepareLinkSettings(ConsistencyGroupCopyUID newProductionCopyUID) throws RecoverPointException {
    logger.info("Preparing link settings between new production copy and local/remote copies after failover.");
    String cgName = null;
    String newProductionCopyName = null;
    try {
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(newProductionCopyUID.getGroupUID());
        List<ConsistencyGroupLinkSettings> cgLinkSettings = groupSettings.getActiveLinksSettings();
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
        newProductionCopyName = functionalAPI.getGroupCopyName(newProductionCopyUID);
        cgName = functionalAPI.getGroupName(newProductionCopyUID.getGroupUID());
        // Go through the existing production copies
        for (ConsistencyGroupCopyUID existingProductionCopyUID : productionCopiesUIDs) {
            List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
            ConsistencyGroupLinkSettings linkSettings = null;
            for (ConsistencyGroupCopySettings copySetting : copySettings) {
                // are identified by not being the existing production copy or the new production copy.
                if (!RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), existingProductionCopyUID) && !RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), newProductionCopyUID)) {
                    String copyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
                    logger.info(String.format("Checking to see if there is an active link between %s and %s.", newProductionCopyName, copyName));
                    // Check to see if a link setting already exists for the link between the 2 copies
                    linkSettings = findLinkSettings(cgLinkSettings, newProductionCopyUID.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), newProductionCopyName, copyName);
                    if (linkSettings == null) {
                        // Link settings for the source/target copies does not exist so we need to create one. Just grab the
                        // first link settings that's available and base the new link off of that.
                        linkSettings = cgLinkSettings.get(0);
                        if (linkSettings != null) {
                            ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
                            firstCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getFirstCopy());
                            firstCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
                            ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
                            secondCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getSecondCopy());
                            secondCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
                            String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
                            String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
                            logger.info(String.format("Generating new link settings between [%s] and [%s] based on existing link settings between copy [%s] and [%s].", newProductionCopyName, copyName, firstCopyName, secondCopyName));
                            ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
                            // Set the link copies appropriately
                            GlobalCopyUID sourceCopy = newProductionCopyUID.getGlobalCopyUID();
                            GlobalCopyUID targetCopy = copySetting.getCopyUID().getGlobalCopyUID();
                            cgLinkUID.setFirstCopy(sourceCopy);
                            cgLinkUID.setSecondCopy(targetCopy);
                            ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
                            // Check the copy cluster information to determine if this is a local or remote copy
                            if (sourceCopy.getClusterUID().getId() == targetCopy.getClusterUID().getId()) {
                                // local copy
                                logger.info(String.format("Creating new local copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
                                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(false);
                            } else {
                                // remote copy
                                logger.info(String.format("Creating new remote copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
                                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
                            }
                            functionalAPI.addConsistencyGroupLink(cgLinkUID, linkPolicy);
                        }
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
    }
}
Also used : FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupLinkUID(com.emc.fapiclient.ws.ConsistencyGroupLinkUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)

Example 2 with GlobalCopyUID

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

the class RecoverPointClient method addReplicationSetsToCG.

/**
 * Updates an existing CG by adding new replication sets.
 *
 * @param request - contains all the information required to create the consistency group
 *
 * @param attachAsClean attach as clean can be true if source and target are guaranteed to be the same (as in create
 *            new volume). for change vpool, attach as clean should be false
 *
 * @return RecoverPointCGResponse - response as to success or fail of creating the consistency group
 *
 * @throws RecoverPointException
 */
public RecoverPointCGResponse addReplicationSetsToCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
    if (null == _endpoint.toASCIIString()) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    RecoverPointCGResponse response = new RecoverPointCGResponse();
    List<ConsistencyGroupCopySettings> groupCopySettings = null;
    ConsistencyGroupUID cgUID = null;
    try {
        // Make sure the CG name is unique.
        List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
                cgUID = settings.getGroupUID();
                groupCopySettings = settings.getGroupCopiesSettings();
                break;
            }
        }
        if (cgUID == null) {
            // The CG does not exist so we cannot add replication sets
            throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
        }
        response.setCgId(cgUID.getId());
        // caches site names to cluster id's to reduce calls to fapi for the same information
        Map<String, ClusterUID> clusterIdCache = new HashMap<String, ClusterUID>();
        // prodSites is used for logging and to determine if a non-production copy is local or remote
        List<ClusterUID> prodSites = new ArrayList<ClusterUID>();
        // used to set the copy uid on the rset volume when adding rsets
        Map<Long, ConsistencyGroupCopyUID> productionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
        Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
        // get a list of CG production copies so we can determine which copies are production and which
        // are not.
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgUID).getProductionCopiesUIDs();
        for (ConsistencyGroupCopySettings copySettings : groupCopySettings) {
            GlobalCopyUID globalCopyUID = copySettings.getCopyUID().getGlobalCopyUID();
            ConsistencyGroupCopyUID copyUID = copySettings.getCopyUID();
            if (RecoverPointUtils.isProductionCopy(copyUID, productionCopiesUIDs)) {
                productionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
                prodSites.add(globalCopyUID.getClusterUID());
            } else {
                nonProductionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
            }
        }
        StringBuffer sb = new StringBuffer();
        for (ClusterUID prodSite : prodSites) {
            sb.append(prodSite.getId());
            sb.append(" ");
        }
        logger.info("RecoverPointClient: Adding replication set(s) to consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
        ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
        logger.info("Adding journals and rsets for CG " + request.getCgName());
        functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
        // Sometimes the CG is still active when we start polling for link state and then
        // starts initializing some time afterwards. Adding this sleep to make sure the CG
        // starts initializing before we check the link states
        waitForRpOperation();
        RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
        logger.info("Waiting for links to become active for CG " + request.getCgName());
        // Wait for the CG link state to be active or paused. We can add replication sets to a CG that has a target
        // copy in DIRECT_ACCESS mode. In this image access mode, the link state is PAUSED and is therefore a valid
        // link state.
        rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID), PipeState.PAUSED);
        logger.info(String.format("Replication sets have been added to consistency group %s.", request.getCgName()));
        response.setReturnCode(RecoverPointReturnCode.SUCCESS);
        return response;
    } catch (Exception e) {
        logger.info("Failed to add replication set(s) to CG");
        throw RecoverPointException.exceptions.failedToAddReplicationSetToConsistencyGroup(request.getCgName(), getCause(e));
    }
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 3 with GlobalCopyUID

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

the class RecoverPointClient method createCgCopyUid.

/**
 * Fetch ConsistencyGroupCopyUID
 *
 * @param cgUID the CG
 * @param clusterUid
 * @param copyType Production, Local or Remote
 * @return ConsistencyGroupCopyUID
 */
private ConsistencyGroupCopyUID createCgCopyUid(ConsistencyGroupUID cgUID, ClusterUID clusterUid, RecoverPointCGCopyType copyType) {
    ConsistencyGroupCopyUID standBycopyUID = new ConsistencyGroupCopyUID();
    GlobalCopyUID globalCopyUID = new GlobalCopyUID();
    globalCopyUID.setClusterUID(clusterUid);
    globalCopyUID.setCopyUID(copyType.getCopyNumber());
    standBycopyUID.setGroupUID(cgUID);
    standBycopyUID.setGlobalCopyUID(globalCopyUID);
    return standBycopyUID;
}
Also used : GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 4 with GlobalCopyUID

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

the class RecoverPointClient method getStandbyCopyLinkSettings.

/**
 * in a Metropoint environment, fetches link(s) between the primary copy(s) and the remote/DR copy
 *
 * @param activeProdCopy the CG copy uid of the active production copy
 * @param standbyProdCopy the CG copy uid of the standby production copy
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIValidationException_Exception
 * @throws RecoverPointException
 */
private List<ConsistencyGroupLinkSettings> getStandbyCopyLinkSettings(ConsistencyGroupCopyUID activeProdCopy, ConsistencyGroupCopyUID standbyProdCopy, String standbyCgCopyName) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
    logger.info("Preparing link settings between standby production copy and remote copy after Metropoint swap production copies.");
    ConsistencyGroupLinkSettings standByCopyLinkSettings = new ConsistencyGroupLinkSettings();
    List<ConsistencyGroupLinkSettings> cgLinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
    String activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopy);
    String cgName = functionalAPI.getGroupName(activeProdCopy.getGroupUID());
    ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(activeProdCopy.getGroupUID());
    // find the remote copy; with metropoint, you're only allowed one remote copy
    // so it must be the one with cluster id not equal to the active or standby cluster ids
    ClusterUID activeClusterId = activeProdCopy.getGlobalCopyUID().getClusterUID();
    ClusterUID standbyClusterId = standbyProdCopy.getGlobalCopyUID().getClusterUID();
    for (ConsistencyGroupCopySettings copySetting : groupSettings.getGroupCopiesSettings()) {
        // see if this is the remote copy; that is it's not the active and not the standby
        ClusterUID copyClusterId = copySetting.getCopyUID().getGlobalCopyUID().getClusterUID();
        if (copyClusterId.getId() != activeClusterId.getId() && copyClusterId.getId() != standbyClusterId.getId()) {
            String targetCopyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
            // get the link settings for the active production copy and remote copy
            ConsistencyGroupLinkSettings linkSettings = findLinkSettings(groupSettings.getActiveLinksSettings(), activeProdCopy.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), activeCgCopyName, targetCopyName);
            if (linkSettings != null) {
                logger.info(String.format("Generate new link settings between %s and %s based on existing link settings between the current production copy %s and %s.", standbyCgCopyName, targetCopyName, activeCgCopyName, targetCopyName));
                cgLinkSettings.add(linkSettings);
                ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
                // Set the link copies appropriately
                GlobalCopyUID standbyCopyUid = standbyProdCopy.getGlobalCopyUID();
                GlobalCopyUID remoteTargetCopyUid = copySetting.getCopyUID().getGlobalCopyUID();
                cgLinkUID.setFirstCopy(standbyCopyUid);
                cgLinkUID.setSecondCopy(remoteTargetCopyUid);
                ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
                // Build the link between the standby production copy and the remote copy
                // this has to be a remote copy
                logger.info(String.format("Build new remote copy link settings between %s and %s, for consistency group %s.", standbyCgCopyName, targetCopyName, cgName));
                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
                standByCopyLinkSettings.setGroupLinkUID(cgLinkUID);
                standByCopyLinkSettings.setLinkPolicy(linkPolicy);
                standByCopyLinkSettings.setLocalLink(false);
                standByCopyLinkSettings.setTransferEnabled(true);
                cgLinkSettings.add(standByCopyLinkSettings);
                break;
            }
        }
    }
    return cgLinkSettings;
}
Also used : ClusterUID(com.emc.fapiclient.ws.ClusterUID) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ArrayList(java.util.ArrayList) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupLinkUID(com.emc.fapiclient.ws.ConsistencyGroupLinkUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings)

Example 5 with GlobalCopyUID

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

the class RecoverPointUtils method mapRPVolumeProtectionInfoToCGCopyUID.

/**
 * @param rpProtectionInfo
 * @return
 */
public static ConsistencyGroupCopyUID mapRPVolumeProtectionInfoToCGCopyUID(RecoverPointVolumeProtectionInfo rpProtectionInfo) {
    ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
    ConsistencyGroupCopyUID cgCopyUID = new ConsistencyGroupCopyUID();
    if (rpProtectionInfo != null) {
        cgUID.setId(rpProtectionInfo.getRpVolumeGroupID());
        cgCopyUID.setGlobalCopyUID(new GlobalCopyUID());
        cgCopyUID.getGlobalCopyUID().setCopyUID(rpProtectionInfo.getRpVolumeGroupCopyID());
        cgCopyUID.setGroupUID(cgUID);
        ClusterUID ClusterUID = new ClusterUID();
        ClusterUID.setId(rpProtectionInfo.getRpVolumeSiteID());
        cgCopyUID.getGlobalCopyUID().setClusterUID(ClusterUID);
    }
    return cgCopyUID;
}
Also used : GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Aggregations

GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)9 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)5 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)4 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)4 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 ConsistencyGroupLinkUID (com.emc.fapiclient.ws.ConsistencyGroupLinkUID)3 FullConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy)3 ArrayList (java.util.ArrayList)3 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)2 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 RecoverPointCGResponse (com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse)1 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)1 HashMap (java.util.HashMap)1