Search in sources :

Example 6 with ConsistencyGroupSettings

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

the class RecoverPointClient method validateRSetsRemoved.

/**
 * Validate that the RSet(s) has been removed from the RP system by calling out
 * to get all RSets for the CG and ensuring the one(s) we are trying to delete is gone.
 *
 * If we still see the RSet(s) being returned, wait and try again until max attempts is
 * reached.
 *
 * @param resetIDsToValidate The RSet IDs to check that they have been removed from RP
 * @param cgToValidate The CG UID to check
 * @param volumeWWNs The WWNs of the source volumes to delete, used for exceptions
 * @throws RecoverPointException RP Exception to throw if we hit it
 */
private void validateRSetsRemoved(List<Long> resetIDsToValidate, ConsistencyGroupUID cgToValidate, List<String> volumeWWNs) throws RecoverPointException {
    try {
        String cgName = functionalAPI.getGroupName(cgToValidate);
        logger.info(String.format("Validating that all requested RSets have been removed from RP CG [%s] (%d)", cgName, cgToValidate.getId()));
        int rsetDeleteAttempt = 0;
        while (rsetDeleteAttempt < MAX_WAIT_FOR_RP_DELETE_ATTEMPTS) {
            boolean allRSetsDeleted = true;
            logger.info(String.format("Validation attempt %d of %d", rsetDeleteAttempt + 1, MAX_WAIT_FOR_RP_DELETE_ATTEMPTS));
            // Get the current RSets from the CG
            ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgToValidate);
            List<ReplicationSetSettings> replicationSetSettings = groupSettings.getReplicationSetsSettings();
            // If any are still present, wait and check again.
            for (ReplicationSetSettings rset : replicationSetSettings) {
                if (resetIDsToValidate.contains(rset.getReplicationSetUID().getId())) {
                    logger.info(String.format("RSet [%s] (%d) has not been removed yet. Will wait and check again...", rset.getReplicationSetName(), rset.getReplicationSetUID().getId()));
                    waitForRpOperation();
                    rsetDeleteAttempt++;
                    allRSetsDeleted = false;
                    // to RecoverPoint to ensure we do not have a stale connection.
                    if (rsetDeleteAttempt == (MAX_WAIT_FOR_RP_DELETE_ATTEMPTS / 2)) {
                        this.reconnect();
                    }
                    break;
                }
            }
            if (allRSetsDeleted) {
                // RSets appear to have been removed from RP
                logger.info(String.format("All requested RSets have been removed from RP CG [%s] (%d).", cgName, cgToValidate.getId()));
                break;
            }
        }
        // If we reached max attempts alert the user and continue on with delete operation.
        if (rsetDeleteAttempt >= MAX_WAIT_FOR_RP_DELETE_ATTEMPTS) {
            // Allow the cleanup to continue in ViPR but warn the user
            logger.error(String.format("Max attempts reached waiting for requested RSets to be removed from RP CG. " + "Please check RP System."));
            throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), new Exception("Max attempts reached waiting for requested RSets to be removed from RP CG. " + "Please check RP System."));
        }
    } catch (Exception e) {
        logger.error(String.format("Exception hit while waiting for all requested RSets to be removed from RP CG."));
        throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), e);
    }
}
Also used : ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) 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)

Example 7 with ConsistencyGroupSettings

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

the class RecoverPointBookmarkManagementUtils method mapCGsForWWNs.

/**
 * Take a list of WWNs for a RecoverPoint appliance and return consistency group information for the WWNs
 *
 * @param impl - RP handle to perform RP operations
 * @param request - Input request of WWNs
 * @param unmappedWWNs - WWNs that could not be mapped to a consistency group
 *
 * @return WWN to consistency group mappings
 *
 * @throws RecoverPointException
 */
public Map<String, RPConsistencyGroup> mapCGsForWWNs(FunctionalAPIImpl impl, CreateBookmarkRequestParams request, Set<String> unmappedWWNs) throws RecoverPointException {
    try {
        Set<String> wwnList = request.getVolumeWWNSet();
        if (wwnList.isEmpty()) {
            logger.error("Input WWN list size is 0");
            return null;
        }
        Map<String, RPConsistencyGroup> returnMap = new HashMap<String, RPConsistencyGroup>();
        Set<String> wwnListCopy = new HashSet<String>();
        for (String wwn : wwnList) {
            wwnListCopy.add(wwn.toLowerCase(Locale.ENGLISH));
            logger.info("Mapping source WWN " + wwn.toLowerCase(Locale.ENGLISH) + " to RecoverPoint CG");
        }
        List<ConsistencyGroupSettings> cgSettings = impl.getAllGroupsSettings();
        RPConsistencyGroup rpCG = null;
        for (ConsistencyGroupSettings cgSetting : cgSettings) {
            for (ReplicationSetSettings rsSetting : cgSetting.getReplicationSetsSettings()) {
                // Only get the unique volumes from a replication set. In MetroPoint, a replication set will list the source volume
                // twice. This is because in MetroPoint each VPLEX leg is considered a copy but the WWN/volume is the same.
                Set<UserVolumeSettings> uvSettings = new HashSet<UserVolumeSettings>();
                uvSettings.addAll(rsSetting.getVolumes());
                for (UserVolumeSettings uvSetting : uvSettings) {
                    String volUID = RecoverPointUtils.getGuidBufferAsString(uvSetting.getVolumeInfo().getRawUids(), false);
                    if (wwnListCopy.contains(volUID.toLowerCase(Locale.ENGLISH))) {
                        // Remove the volUID from the list
                        wwnListCopy.remove(volUID.toLowerCase(Locale.ENGLISH));
                        // We are getting the index of the first production copy because we only need to
                        // get the cluster ID of the source. All source copies in a CG, across different Rsets, are on the same cluster.
                        // Hence we are ok fetching the first one and getting its cluster id and using it.
                        ConsistencyGroupCopyUID productionCopyUID = cgSetting.getProductionCopiesUIDs().get(0);
                        // Get the RecoverPoint CG name and ID
                        String cgName = cgSetting.getName();
                        ConsistencyGroupUID cgUID = cgSetting.getGroupUID();
                        // Get the Copy information
                        RPCopy rpCopy = new RPCopy();
                        rpCopy.setCGGroupCopyUID(uvSetting.getGroupCopyUID());
                        Set<RPCopy> copies = new HashSet<RPCopy>();
                        copies.add(rpCopy);
                        logger.info("Source WWN: " + volUID + " is on RecoverPoint CG " + cgName + " with RecoverPoint CGID " + cgUID.getId());
                        rpCG = new RPConsistencyGroup();
                        rpCG.setName(cgName);
                        rpCG.setCGUID(cgUID);
                        rpCG.setClusterUID(productionCopyUID.getGlobalCopyUID().getClusterUID());
                        rpCG.setSiteToArrayIDsMap(mapCGToStorageArraysNoConnection(cgSetting));
                        rpCG.setCopies(copies);
                        returnMap.put(volUID, rpCG);
                        break;
                    }
                }
            }
            if (wwnListCopy.isEmpty()) {
                break;
            }
        }
        for (String wwnMissing : wwnListCopy) {
            logger.error("Could not map WWN: " + wwnMissing);
            unmappedWWNs.add(wwnMissing);
        }
        return returnMap;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage());
        return null;
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage());
        return null;
    }
}
Also used : UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet)

Example 8 with ConsistencyGroupSettings

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

the class RecoverPointBookmarkManagementUtils method getBookmarksForMostRecentBookmarkName.

/**
 * Find the most recent bookmarks that were created for a CG with a given name
 *
 * @param impl - RP handle to use for RP operations
 * @param request - Information about the bookmark that was created on the CGs
 * @param cgUID - The CG to look for bookmarks
 *
 * @return A set of RP bookmarks found on the CG
 *
 * @throws RecoverPointException
 */
private Set<RPBookmark> getBookmarksForMostRecentBookmarkName(FunctionalAPIImpl impl, CreateBookmarkRequestParams request, ConsistencyGroupUID cgUID) throws RecoverPointException {
    Set<RPBookmark> returnBookmarkSet = null;
    try {
        String bookmarkName = request.getBookmark();
        Set<RPBookmark> bookmarkSet = new HashSet<RPBookmark>();
        ConsistencyGroupSettings cgSettings = impl.getGroupSettings(cgUID);
        List<ConsistencyGroupCopySettings> cgCopySettings = cgSettings.getGroupCopiesSettings();
        ConsistencyGroupCopyUID prodCopyUID = cgSettings.getLatestSourceCopyUID();
        for (ConsistencyGroupCopySettings cgcopysetting : cgCopySettings) {
            RPBookmark newEM = new RPBookmark();
            newEM.setCGGroupCopyUID(cgcopysetting.getCopyUID());
            newEM.setBookmarkName(bookmarkName);
            newEM.setBookmarkTime(null);
            bookmarkSet.add(newEM);
        }
        logger.debug("Getting list of snapshots with event marker name: " + bookmarkName);
        List<ConsistencyGroupCopySnapshots> cgCopySnapList = impl.getGroupSnapshots(cgUID).getCopiesSnapshots();
        for (ConsistencyGroupCopySnapshots cgCopySnap : cgCopySnapList) {
            ConsistencyGroupCopyUID copyUID = cgCopySnap.getCopyUID();
            logger.debug("Found " + cgCopySnap.getSnapshots().size() + " snapshots on copy: " + copyUID.getGlobalCopyUID().getCopyUID());
            for (Snapshot snapItem : cgCopySnap.getSnapshots()) {
                if (snapItem.getDescription().equals(bookmarkName)) {
                    for (RPBookmark rpBookmark : bookmarkSet) {
                        ConsistencyGroupCopyUID rpBookmarkCopyCG = rpBookmark.getCGGroupCopyUID();
                        if (RecoverPointUtils.copiesEqual(copyUID, rpBookmarkCopyCG)) {
                            // Update record with bookmark time, and add back
                            rpBookmark.setBookmarkTime(snapItem.getClosingTimeStamp());
                            Timestamp protectionTimeStr = new Timestamp(snapItem.getClosingTimeStamp().getTimeInMicroSeconds() / numMicroSecondsInMilli);
                            // Remove it, and add it back
                            RPBookmark updatedBookmark = new RPBookmark();
                            updatedBookmark.setBookmarkTime(snapItem.getClosingTimeStamp());
                            updatedBookmark.setCGGroupCopyUID(rpBookmark.getCGGroupCopyUID());
                            logger.info("Found our bookmark with time: " + protectionTimeStr.toString() + " and group copy ID: " + rpBookmark.getCGGroupCopyUID().getGlobalCopyUID().getCopyUID());
                            updatedBookmark.setBookmarkName(rpBookmark.getBookmarkName());
                            updatedBookmark.setProductionCopyUID(prodCopyUID);
                            if (returnBookmarkSet == null) {
                                returnBookmarkSet = new HashSet<RPBookmark>();
                            }
                            // TODO: logic is suspect, need to revisit. Why are we removing and adding the same object??
                            returnBookmarkSet.remove(updatedBookmark);
                            returnBookmarkSet.add(updatedBookmark);
                        }
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.exceptionLookingForBookmarks(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.exceptionLookingForBookmarks(e);
    }
    logger.debug("Return set has " + ((returnBookmarkSet != null) ? returnBookmarkSet.size() : 0) + " items");
    return ((returnBookmarkSet != null) ? returnBookmarkSet : null);
}
Also used : FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) Timestamp(java.sql.Timestamp) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) Snapshot(com.emc.fapiclient.ws.Snapshot) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupCopySnapshots(com.emc.fapiclient.ws.ConsistencyGroupCopySnapshots) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) RPBookmark(com.emc.storageos.recoverpoint.objectmodel.RPBookmark) HashSet(java.util.HashSet)

Example 9 with ConsistencyGroupSettings

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

the class RecoverPointImageManagementUtils method isSnapShotTechnologyEnabled.

/**
 * Determines if the specified consistency group is using snapshot technology
 * Returns true if the RP source copy is using snapshot technology, false otherwise
 *
 * @param impl the FAPI reference.
 * @param cgCopyUID the copy to be set as the production copy.
 * @throws RecoverPointException
 * @return boolean indicating if snapshot technology is being used
 */
private static boolean isSnapShotTechnologyEnabled(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID) throws RecoverPointException {
    String cgName = "unknown";
    try {
        cgName = impl.getGroupName(cgUID);
        ConsistencyGroupSettings groupSettings = impl.getGroupSettings(cgUID);
        List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
        for (ConsistencyGroupCopySettings copySetting : copySettings) {
            if (copySetting.getRoleInfo().getRole().equals(ConsistencyGroupCopyRole.ACTIVE) && copySetting.getPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() != null && copySetting.getPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() > 0) {
                logger.info("Setting link state for snapshot technology.");
                return true;
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    return false;
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings)

Example 10 with ConsistencyGroupSettings

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

the class RecoverPointUtils method verifyCGVolumesAttachedToSplitter.

/**
 * verify that the volumes in a consistency group are connected to a splitter
 *
 * @param impl - handle for FAPI
 * @param groupUID - consistency group to examine volumes on
 * @throws - RecoverPointException
 */
public static void verifyCGVolumesAttachedToSplitter(FunctionalAPIImpl impl, ConsistencyGroupUID groupUID) throws RecoverPointException {
    ConsistencyGroupSettings groupSettings;
    try {
        groupSettings = impl.getGroupSettings(groupUID);
        // Get the consistency group settings
        for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
            // Run over all replication sets
            for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
                logger.info("Volume : " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is of type " + userVolume.getVolumeType());
                if (userVolume.getAttachedSplitters().isEmpty()) {
                    String volumeWWN = RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false);
                    logger.warn("Volume " + volumeWWN + " is not attached to any splitters");
                    Set<SplitterUID> splittersToAttachTo = getSplittersToAttachToForVolume(impl, userVolume.getClusterUID(), userVolume.getVolumeInfo().getVolumeID());
                    for (SplitterUID splitterUID : splittersToAttachTo) {
                        SetVolumeParam volumeParam = new SetVolumeParam();
                        volumeParam.setShouldAttachAsClean(false);
                        volumeParam.setVolumeID(userVolume.getVolumeInfo().getVolumeID());
                        logger.info("Attaching volume " + volumeWWN + " to splitter" + impl.getSplitterName(splitterUID));
                        impl.attachVolumeToSplitter(splitterUID, volumeParam);
                    }
                } else {
                    for (SplitterUID splitterUID : userVolume.getAttachedSplitters()) {
                        logger.info("Volume " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is attached to splitter " + impl.getSplitterName(splitterUID));
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SetVolumeParam(com.emc.fapiclient.ws.SetVolumeParam) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Aggregations

ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)17 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)15 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)15 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)8 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)8 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)7 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)5 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)5 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 ClusterUID (com.emc.fapiclient.ws.ClusterUID)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)3 ReplicationSetUID (com.emc.fapiclient.ws.ReplicationSetUID)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)2 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)2