Search in sources :

Example 16 with ConsistencyGroupCopyUID

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

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

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

the class RecoverPointImageManagementUtils method enableCGCopyDirectAcess.

/**
 * Enables CG direct access mode on the specified copy.
 *
 * @param impl the FAPI implementation
 * @param copyToEnableDirectAccess the copy to enable direct access on
 * @throws RecoverPointException
 */
public void enableCGCopyDirectAcess(FunctionalAPIImpl impl, RPCopyRequestParams copyToEnableDirectAccess) throws RecoverPointException {
    String cgCopyName = NAME_UNKNOWN;
    String cgName = NAME_UNKNOWN;
    String accessState = "N/A";
    // Not checking cgCopUID for null because RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID
    // ensures it will not be null.
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToEnableDirectAccess.getCopyVolumeInfo());
    try {
        cgCopyName = impl.getGroupCopyName(cgCopyUID);
        cgName = impl.getGroupName(cgCopyUID.getGroupUID());
        // Get the storage access state prior to enabling direct access. In the event of a failure,
        // we want to present the current state of the copy to the user.
        ConsistencyGroupCopyState copyState = getCopyState(impl, cgCopyUID);
        if (copyState != null && copyState.getStorageAccessState() != null) {
            accessState = copyState.getStorageAccessState().name();
        }
        impl.enableDirectAccess(cgCopyUID);
        // Wait for the CG copy state to change to DIRECT_ACCESS
        logger.info(String.format("Waiting for copy %s in consistency group %s to change access state to DIRECT_ACCESS.", cgCopyName, cgName));
        waitForCGCopyState(impl, cgCopyUID, false);
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception | InterruptedException e) {
        throw RecoverPointException.exceptions.failedToEnableDirectAccessForCopy(cgCopyName, cgName, e, accessState);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 19 with ConsistencyGroupCopyUID

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

the class RecoverPointImageManagementUtils method disableCopyImage.

/**
 * Perform an disable image on a CG copy
 *
 * @param impl - RP handle to use for RP operations
 * @param copyToEnableTo - CG to disable
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void disableCopyImage(FunctionalAPIImpl impl, RPCopyRequestParams copyToEnableTo) throws RecoverPointException {
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToEnableTo.getCopyVolumeInfo());
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    imageManager.disableCGCopy(impl, cgCopyUID);
}
Also used : ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 20 with ConsistencyGroupCopyUID

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

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