Search in sources :

Example 36 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointBookmarkManagementUtils method getRPBookmarksForCG.

/**
 * Find the bookmarks associated with a consistency group
 *
 * @param impl - RP handle to use for RP operations
 * @param cgUID - The CG to look for bookmarks
 *
 * @return A set of RP bookmarks found on the CG
 *
 * @throws RecoverPointException
 */
public List<RPBookmark> getRPBookmarksForCG(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID) throws RecoverPointException {
    List<RPBookmark> returnBookmarkSet = null;
    try {
        logger.debug("Getting list of snapshots for CG: " + cgUID.getId());
        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()) {
                // We're not interested in bookmarks without names
                if (snapItem.getDescription() != null && !snapItem.getDescription().isEmpty()) {
                    RPBookmark bookmark = new RPBookmark();
                    bookmark.setBookmarkTime(snapItem.getClosingTimeStamp());
                    bookmark.setCGGroupCopyUID(cgCopySnap.getCopyUID());
                    bookmark.setBookmarkName(snapItem.getDescription());
                    if (returnBookmarkSet == null) {
                        returnBookmarkSet = new ArrayList<RPBookmark>();
                    }
                    returnBookmarkSet.add(bookmark);
                    logger.debug("Recording bookmark: " + bookmark.getBookmarkName());
                }
            }
        }
    } 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 : Snapshot(com.emc.fapiclient.ws.Snapshot) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopySnapshots(com.emc.fapiclient.ws.ConsistencyGroupCopySnapshots) RPBookmark(com.emc.storageos.recoverpoint.objectmodel.RPBookmark) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 37 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method enableCopyImage.

/**
 * Perform an enable image on a CG copy
 *
 * @param impl - RP handle to use for RP operations
 * @param copyToEnableTo - CG to enable, as well as the bookmark and APIT
 * @param failover - whether this operation is a failover or not. Affects current copy check.
 * @return void
 *
 * @throws RecoverPointException
 */
public void enableCopyImage(FunctionalAPIImpl impl, RPCopyRequestParams copyToEnableTo, boolean failover) throws RecoverPointException {
    // Check the params
    // If bookmark != null, enable the bookmark on the copy, and failover to that copy
    // If APITTime != null, enable the specified APIT on the copy, and failover to that copy
    // If both are null, enable the most recent imagem, and failover to that copy
    String bookmarkName = copyToEnableTo.getBookmarkName();
    Date apitTime = copyToEnableTo.getApitTime();
    // FunctionalAPIImpl impl = new RecoverPointConnection().connect(endpoint, username, password);
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToEnableTo.getCopyVolumeInfo());
    if (bookmarkName != null) {
        logger.info("Enable copy to bookmark : " + bookmarkName);
    } else if (apitTime != null) {
        logger.info("Enable copy to APIT : " + apitTime.toString());
    } else {
        logger.info("Enable copy to most recent image");
    }
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    // Will throw an exception if it's not in the right state
    if (!imageManager.verifyCopyCapableOfEnableImageAccess(impl, cgCopyUID, copyToEnableTo.getBookmarkName(), failover)) {
        try {
            String cgCopyName = impl.getGroupCopyName(cgCopyUID);
            String cgName = impl.getGroupName(cgCopyUID.getGroupUID());
            logger.info("Copy " + cgCopyName + " of group " + cgName + " is in a mode that disallows enabling the CG copy.");
            throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCG(cgName, cgCopyName);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
        }
    }
    boolean waitForLinkState = false;
    imageManager.enableCGCopy(impl, cgCopyUID, waitForLinkState, ImageAccessMode.LOGGED_ACCESS, bookmarkName, apitTime);
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) Date(java.util.Date) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 38 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method verifyCopyCapableOfEnableImageAccess.

/**
 * Verify that a copy is capable of being enabled.
 *
 * @param impl - RP handle
 * @param cgCopy - CG Copy, contains CG
 * @param failover - for a failover operation?
 * @return true if the copy is capable of enable image access, false if it's in some other state
 * @throws RecoverPointException
 */
public boolean verifyCopyCapableOfEnableImageAccess(FunctionalAPIImpl impl, ConsistencyGroupCopyUID cgCopy, String copyToEnable, boolean failover) throws RecoverPointException {
    String cgCopyName = NAME_UNKNOWN;
    String cgName = NAME_UNKNOWN;
    try {
        cgCopyName = impl.getGroupCopyName(cgCopy);
        cgName = impl.getGroupName(cgCopy.getGroupUID());
        ConsistencyGroupCopyState cgCopyState = getCopyState(impl, cgCopy);
        if (cgCopyState != null) {
            StorageAccessState copyAccessState = cgCopyState.getStorageAccessState();
            logger.info("Current Copy Access State: " + copyAccessState);
            // Check for NO_ACCESS state (or LOGGED ACCESS for failover)
            if (copyAccessState == StorageAccessState.NO_ACCESS) {
                return true;
            }
            // Failover-test state
            if ((copyAccessState == StorageAccessState.LOGGED_ACCESS) && failover) {
                ConsistencyGroupLinkState cgLinkState = getCopyLinkState(impl, cgCopy);
                if ((cgLinkState != null) && (cgLinkState.getPipeState() == PipeState.PAUSED)) {
                    return true;
                }
            }
            // return true if CG is already in LOGGED_ACCESS state
            if (copyAccessState == StorageAccessState.LOGGED_ACCESS && cgCopyState.getAccessedImage().getDescription().equals(copyToEnable)) {
                return true;
            }
        }
        return false;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    }
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState)

Example 39 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method waitForCGLinkState.

/**
 * Wait for CG copy links to become ACTIVE
 *
 * @param cgUID - Consistency group we are looking at
 * @param desiredPipeState - Desired state of the pipe
 * @param port - RP handle to use for RP operations
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGLinkState(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID, PipeState... desiredPipeState) throws RecoverPointException {
    int numRetries = 0;
    String cgName = null;
    try {
        cgName = impl.getGroupName(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    boolean isInitializing = false;
    boolean allLinksInDesiredState = false;
    while ((!allLinksInDesiredState && numRetries++ < MAX_RETRIES) || isInitializing) {
        ConsistencyGroupState cgState = null;
        isInitializing = false;
        try {
            cgState = impl.getGroupState(cgUID);
            List<String> desiredPipeStates = new ArrayList<String>();
            if (desiredPipeState != null) {
                // build the list of desired pipe states
                for (PipeState pipeState : desiredPipeState) {
                    desiredPipeStates.add(pipeState.name());
                }
            }
            // allLinksInDesiredState = true;
            for (ConsistencyGroupLinkState linkstate : cgState.getLinksStates()) {
                PipeState pipeState = linkstate.getPipeState();
                logger.info("CG link state is " + pipeState.toString() + "; desired states are: " + desiredPipeStates.toString());
                // Special consideration if we want the link to be in the active state.
                if (desiredPipeStates.contains(PipeState.ACTIVE.name())) {
                    if (PipeState.ACTIVE.equals(pipeState)) {
                        allLinksInDesiredState = true;
                    } else if (PipeState.STAND_BY.equals(pipeState)) {
                        // STAND_BY is a valid state for a MetroPoint link but we need
                        // an ACTIVE link state as well.
                        logger.info("CG link state is STAND_BY, valid state for MetroPoint.");
                    } else if (PipeState.PAUSED.equals(pipeState)) {
                        if (desiredPipeStates.contains(PipeState.PAUSED.name())) {
                            // When DIRECT_ACCESS mode is set on a target copy, the link will be paused. If one of
                            // the desired states is PAUSED, we must respect that and not attempt to start group
                            // transfer.
                            logger.info("CG link state is PAUSED.");
                            allLinksInDesiredState = true;
                        } else {
                            // We only want to start group transfer if the only desired state is the active state. When
                            // target copies are in DIRECT_ACCESS mode, the link will be paused and we do not want
                            // to resume group transfer.
                            logger.info("CG link state is PAUSED.  Resume link.");
                            impl.startGroupTransfer(cgUID);
                            allLinksInDesiredState = false;
                            break;
                        }
                    } else if (PipeState.INITIALIZING.equals(pipeState)) {
                        logger.info("CG link state is INITIALIZING.");
                        isInitializing = true;
                        allLinksInDesiredState = false;
                        break;
                    } else {
                        logger.info("CG link state is not active. It is: " + pipeState.toString());
                        allLinksInDesiredState = false;
                        break;
                    }
                } else if (desiredPipeStates.contains(PipeState.SNAP_IDLE.name())) {
                    if (PipeState.SNAP_IDLE.equals(pipeState) || PipeState.SNAP_SHIPPING.equals(pipeState)) {
                        allLinksInDesiredState = true;
                        break;
                    }
                } else {
                    // Other desired states (like UNKNOWN [inactive])
                    if (desiredPipeStates.contains(pipeState.name())) {
                        logger.info("CG link state matches the desired state.");
                        allLinksInDesiredState = true;
                    } else {
                        // This makes sure that if you wanted to act on the entire CG, but there's still a copy
                        // in the undesired state, we still need to wait for it.
                        logger.info("CG link state is not in desired state. It is: " + pipeState.toString());
                        allLinksInDesiredState = false;
                        break;
                    }
                }
            }
            if (allLinksInDesiredState) {
                return;
            } else {
                logger.info("All links not in desired state.  Sleep 15 seconds and retry");
                Thread.sleep(WAIT_FOR_LINKS_SLEEP_INTERVAL);
            }
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (InterruptedException e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        }
    }
    throw RecoverPointException.exceptions.cgLinksFailedToBecomeActive(cgName);
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ArrayList(java.util.ArrayList) PipeState(com.emc.fapiclient.ws.PipeState) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 40 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method waitForCGCopyLinkState.

/**
 * Wait for CG copy links to become ACTIVE
 *
 * @param impl access to RP
 * @param copyUID copy ID
 * @param desiredPipeState - Desired state of the pipe
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyUID, PipeState... desiredPipeState) throws RecoverPointException {
    int numRetries = 0;
    String cgName = null;
    try {
        cgName = impl.getGroupName(copyUID.getGroupUID());
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    List<String> desiredPipeStates = new ArrayList<String>();
    if (desiredPipeState != null) {
        // build the list of desired pipe states
        for (PipeState pipeState : desiredPipeState) {
            desiredPipeStates.add(pipeState.name());
        }
    }
    while (numRetries++ < MAX_RETRIES) {
        ConsistencyGroupState cgState = null;
        try {
            cgState = impl.getGroupState(copyUID.getGroupUID());
            for (ConsistencyGroupLinkState linkstate : cgState.getLinksStates()) {
                // The copy we're interested in may be in the FirstCopy or SecondCopy, so we need to find the link
                // state where our copy is the first or second copy and the other copy is a production. There may be
                // multiple production copies, so account for that, too. (you can assume there aren't multiple productions
                // going to the same target. We used to assume that the targets are "second copy", but that is not true.
                boolean found = false;
                // Loop through production copies
                if (!cgState.getSourceCopiesUIDs().isEmpty()) {
                    for (ConsistencyGroupCopyUID groupCopyUID : cgState.getSourceCopiesUIDs()) {
                        if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
                            found = true;
                        }
                        if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID())) {
                            found = true;
                        }
                    }
                } else {
                    // the link source and copy. Just find our copy in the link and go with it.
                    if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID()) || RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
                        found = true;
                    }
                }
                if (!found) {
                    continue;
                }
                if (desiredPipeStates.contains(PipeState.ACTIVE.name())) {
                    // Treat SNAP_IDLE as ACTIVE
                    if (linkstate.getPipeState().equals(PipeState.SNAP_IDLE)) {
                        linkstate.setPipeState(PipeState.ACTIVE);
                    }
                }
                PipeState pipeState = linkstate.getPipeState();
                logger.info("Copy link state is " + pipeState.toString() + "; desired states are: " + desiredPipeStates.toString());
                if (desiredPipeStates.contains(pipeState.name())) {
                    logger.info("Copy link state matches the desired state.");
                    return;
                } else {
                    // This makes sure that if you wanted to act on the entire CG, but there's still a copy
                    // in the undesired state, we still need to wait for it.
                    logger.info("Copy link state is not in desired state. It is: " + pipeState.toString());
                    break;
                }
            }
            logger.info("Copy link not in desired state.  Sleep 15 seconds and retry");
            Thread.sleep(WAIT_FOR_LINKS_SLEEP_INTERVAL);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (InterruptedException e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        }
    }
    throw RecoverPointException.exceptions.cgLinksFailedToBecomeActive(cgName);
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ArrayList(java.util.ArrayList) PipeState(com.emc.fapiclient.ws.PipeState) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)42 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)42 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)21 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)15 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)11 HashSet (java.util.HashSet)10 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)7 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)7 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)5 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)5 HashMap (java.util.HashMap)5 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)3 ConsistencyGroupCopySnapshots (com.emc.fapiclient.ws.ConsistencyGroupCopySnapshots)3 DeviceUID (com.emc.fapiclient.ws.DeviceUID)3