Search in sources :

Example 26 with ConsistencyGroupUID

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

the class RecreateReplicationSetRequestParams method getConsistencyGroupUID.

public ConsistencyGroupUID getConsistencyGroupUID() {
    ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
    cgUID.setId(cgID);
    return cgUID;
}
Also used : ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID)

Example 27 with ConsistencyGroupUID

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

the class RecoverPointBookmarkManagementUtils method createCGBookmarks.

/**
 * Create bookmarks for a CG
 *
 * @param impl - RP handle to use for RP operations
 * @param rpCGMap - The mapping of RP CGs to WWNs. Used to create a list of CGs to bookmark
 * @param request - Information about the bookmark to request
 *
 * @return CreateBookmarkResponse - Results of the create bookmark.
 *         TODO: Return bookmark information (date/time)
 *
 * @throws RecoverPointException
 */
public CreateBookmarkResponse createCGBookmarks(FunctionalAPIImpl impl, Map<String, RPConsistencyGroup> rpCGMap, CreateBookmarkRequestParams request) throws RecoverPointException {
    Set<ConsistencyGroupUID> uniqueCGUIDSet = new HashSet<ConsistencyGroupUID>();
    List<ConsistencyGroupUID> uniqueCGUIDlist = new LinkedList<ConsistencyGroupUID>();
    Set<RPConsistencyGroup> rpCGSet = new HashSet<RPConsistencyGroup>();
    CreateBookmarkResponse response = new CreateBookmarkResponse();
    for (String volume : rpCGMap.keySet()) {
        RPConsistencyGroup rpCG = rpCGMap.get(volume);
        if (rpCG.getCGUID() != null) {
            boolean foundCGUID = false;
            ConsistencyGroupUID cguid = rpCG.getCGUID();
            for (ConsistencyGroupUID cguidunique : uniqueCGUIDSet) {
                if (cguidunique.getId() == cguid.getId()) {
                    foundCGUID = true;
                    break;
                }
            }
            if (!foundCGUID) {
                logger.info("Adding CG: " + rpCG.getName() + " with ID " + rpCG.getCGUID().getId() + " to unique CGUID list");
                uniqueCGUIDSet.add(cguid);
                uniqueCGUIDlist.add(cguid);
                rpCGSet.add(rpCG);
            }
        }
    }
    // Make sure the CG is in a good state before we make bookmarks
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    for (ConsistencyGroupUID cgID : uniqueCGUIDlist) {
        // Make sure the CG is ready for enable
        imageManager.waitForCGLinkState(impl, cgID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgID), PipeState.PAUSED);
    }
    try {
        impl.createBookmark(uniqueCGUIDlist, request.getBookmark(), BookmarkConsolidationPolicy.NEVER_CONSOLIDATE, SnapshotConsistencyType.APPLICATION_CONSISTENT);
        logger.info(String.format("Created RP Bookmark successfully: %s", request.getBookmark()));
        response.setCgBookmarkMap(findRPBookmarks(impl, rpCGSet, request));
        response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToCreateBookmarkOnRecoverPoint(e);
    }
    return response;
}
Also used : FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) LinkedList(java.util.LinkedList) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkResponse(com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) HashSet(java.util.HashSet)

Example 28 with ConsistencyGroupUID

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

the class RecoverPointImageManagementUtils method verifyGroupCopyImageIsEnabled.

/**
 * Verify that a group copy image is enabled. Not a "wait for", just a check
 *
 * @param port - RP handle to use for RP operations
 * @param groupCopy - CG copy we are checking
 * @param expectLoggedAccess - We are explicitly checking for LOGGED_ACCESS
 * @param bookmarkName - A bookmark we are expecting to be enabled (null means don't care)
 *
 * @return boolean - true (enabled) or false (not enabled)
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
private boolean verifyGroupCopyImageIsEnabled(FunctionalAPIImpl port, ConsistencyGroupCopyUID groupCopy, boolean expectLoggedAccess, String bookmarkName) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, RecoverPointException {
    ConsistencyGroupUID groupUID = groupCopy.getGroupUID();
    ConsistencyGroupState groupState;
    List<ConsistencyGroupCopyState> groupCopyStateList;
    groupState = port.getGroupState(groupUID);
    groupCopyStateList = groupState.getGroupCopiesStates();
    String cgName = port.getGroupName(groupCopy.getGroupUID());
    String cgCopyName = port.getGroupCopyName(groupCopy);
    boolean isAPITCheck = false;
    RecoverPointTimeStamp apitTimeStamp = null;
    if (bookmarkName == null) {
        // Most "recent"
        isAPITCheck = true;
    } else {
        apitTimeStamp = new RecoverPointTimeStamp();
        isAPITCheck = true;
        apitTimeStamp.setTimeInMicroSeconds(Long.parseLong(bookmarkName) * numMicroSecondsInMilli);
    }
    logger.info("verifyGroupCopyImageIsEnabled called for copy " + cgCopyName + " of group " + cgName + " and bookmarkName/APIT: " + bookmarkName);
    for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
        if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
            StorageAccessState accessState = groupCopyState.getStorageAccessState();
            if (expectLoggedAccess) {
                // Explicitly looking for LOGGED_ACCESS
                logger.debug("Seeing if copy is enabled for LOGGED_ACCESS");
                if (accessState == StorageAccessState.LOGGED_ACCESS) {
                    if (!bookmarkName.equals(groupCopyState.getAccessedImage().getDescription())) {
                        // Enabled, but for a different snapshot image
                        if (groupCopyState.getAccessedImage().getDescription().length() > 0) {
                            throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, groupCopyState.getAccessedImage().getDescription());
                        } else {
                            Timestamp enabledAPITTime = null;
                            RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
                            enabledAPITTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
                            throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, enabledAPITTime.toString());
                        }
                    }
                    logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " IS enabled in LOGGED_ACCESS");
                    return true;
                } else {
                    logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is NOT enabled in LOGGED_ACCESS. Image state is: " + accessState.toString());
                    return false;
                }
            }
            logger.debug("Seeing if copy is enabled for any access mode other than DIRECT_ACCESS or NO_ACCESS");
            if (accessState == StorageAccessState.DIRECT_ACCESS) {
                logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in direct access mode");
                return false;
            }
            if (accessState == StorageAccessState.NO_ACCESS) {
                logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in NO access mode");
                return false;
            }
            if (groupCopyState.getAccessedImage() != null) {
                logger.info("Copy image IS enabled. State is: " + accessState.toString() + ". Mounted snapshot name: " + groupCopyState.getAccessedImage().getDescription());
            } else {
                logger.info("Copy image IS enabled. State is: " + accessState.toString() + ". Enabled image: restore state");
            }
            // Let's throw if its the wrong image, otherwise return true
            if (!isAPITCheck) {
                if ((bookmarkName == null) && (groupCopyState.getAccessedImage() == null)) {
                    return true;
                }
                if ((bookmarkName != null) && !bookmarkName.equals(groupCopyState.getAccessedImage().getDescription())) {
                    // Enabled, but for a different snapshot image
                    if (groupCopyState.getAccessedImage().getDescription().length() > 0) {
                        throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, groupCopyState.getAccessedImage().getDescription());
                    } else {
                        Timestamp enabledAPITTime = null;
                        RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
                        enabledAPITTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
                        throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, enabledAPITTime.toString());
                    }
                }
                return true;
            } else {
                if (bookmarkName == null) {
                    return true;
                } else {
                    return isGroupCopyImageEnabledForAPIT(port, groupCopy, expectLoggedAccess, apitTimeStamp);
                }
            }
        }
    }
    logger.error("Could not locate CG copy state");
    return false;
}
Also used : RecoverPointTimeStamp(com.emc.fapiclient.ws.RecoverPointTimeStamp) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState) Timestamp(java.sql.Timestamp) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 29 with ConsistencyGroupUID

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

the class RecoverPointImageManagementUtils method waitForCGCopyState.

/**
 * Wait for a CG copy to change state
 *
 * @param impl - the FAPI implementation
 * @param groupCopy - RP group copy we are looking at
 * @param accessState - Access modes we are waiting for
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGCopyState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID groupCopy, StorageAccessState accessState) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, InterruptedException, RecoverPointException {
    if (accessState == null) {
        throw RecoverPointException.exceptions.waitForInvalidCopyState("null");
    }
    ConsistencyGroupUID groupUID = groupCopy.getGroupUID();
    List<ConsistencyGroupCopyState> groupCopyStateList;
    String cgName = impl.getGroupName(groupCopy.getGroupUID());
    String cgCopyName = impl.getGroupCopyName(groupCopy);
    final int maxMinutes = 30;
    // seconds
    final int sleepTimeSeconds = 15;
    final int secondsPerMin = 60;
    final int numItersPerMin = secondsPerMin / sleepTimeSeconds;
    logger.info(String.format("Waiting up to %d minutes for consistency group copy state to change to %s.  Copy name: %s, consistency group name: %s.", maxMinutes, accessState.toString(), cgCopyName, cgName));
    for (int minIter = 0; minIter < maxMinutes; minIter++) {
        for (int perMinIter = 0; perMinIter < numItersPerMin; perMinIter++) {
            groupCopyStateList = impl.getGroupState(groupUID).getGroupCopiesStates();
            for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
                if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
                    StorageAccessState copyAccessState = groupCopyState.getStorageAccessState();
                    logger.info("Current Copy Access State: " + copyAccessState);
                    if (copyAccessState.equals(accessState)) {
                        logger.info(String.format("Copy %s of group %s is in %s state.", cgCopyName, cgName, copyAccessState.toString()));
                        return;
                    }
                }
            }
            logger.info("Copy image " + cgCopyName + " of group " + cgName + " not in correct state.  Sleeping " + sleepTimeSeconds + " seconds");
            try {
                Thread.sleep(Long.valueOf(sleepTimeSeconds * numMillisInSecond));
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
    throw RecoverPointException.exceptions.stateChangeNeverCompleted();
}
Also used : ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState)

Aggregations

ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)29 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)21 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)21 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)14 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)8 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)7 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ClusterUID (com.emc.fapiclient.ws.ClusterUID)5 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)5 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)4 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)4 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)4 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)2 FullConsistencyGroupPolicy (com.emc.fapiclient.ws.FullConsistencyGroupPolicy)2