Search in sources :

Example 6 with ConsistencyGroupState

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

the class RecoverPointClient method getAllCGs.

/**
 * Returns all CGs, policies, and volumes within the CG.
 *
 * @return a set of RP consistency group objects
 * @throws RecoverPointException
 */
public Set<GetCGsResponse> getAllCGs() throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    // TODO: Refactor to break down into smaller pieces
    Set<GetCGsResponse> cgs = new HashSet<GetCGsResponse>();
    try {
        // Quickly get a map of cluster/sitenames
        Map<Long, String> clusterIdToInternalSiteNameMap = new HashMap<Long, String>();
        FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
        for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
            clusterIdToInternalSiteNameMap.put(siteSettings.getCluster().getId(), siteSettings.getInternalClusterName());
        }
        // Go through all of the CGs and retrieve important pieces of information
        List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            ConsistencyGroupState state = functionalAPI.getGroupState(cg);
            logger.info("Processing CG found on RecoverPoint system: " + settings.getName());
            // First storage attributes about the top-level CG
            GetCGsResponse cgResp = new GetCGsResponse();
            cgResp.setCgName(settings.getName());
            cgResp.setCgId(cg.getId());
            cgResp.setCgPolicy(new GetCGsResponse.GetPolicyResponse());
            // Find and store the policy information
            if (settings.getActiveLinksSettings() != null) {
                for (ConsistencyGroupLinkSettings cgls : settings.getActiveLinksSettings()) {
                    if (cgls.getLinkPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy() != null) {
                        if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType() != null) {
                            if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType().toString().equalsIgnoreCase(ProtectionMode.SYNCHRONOUS.toString())) {
                                cgResp.getCgPolicy().synchronous = true;
                            } else {
                                cgResp.getCgPolicy().synchronous = false;
                            }
                        }
                        if (cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag() != null) {
                            cgResp.getCgPolicy().rpoType = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getType().name();
                            cgResp.getCgPolicy().rpoValue = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getValue();
                        }
                    }
                }
            }
            // We assume CG health until we see something that indicates otherwise.
            cgResp.setCgState(GetCGsResponse.GetCGStateResponse.HEALTHY);
            RecoverPointCGState cgState = this.getCGState(cg);
            if (cgState.equals(RecoverPointCGState.DELETED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_ERROR);
            } else if (cgState.equals(RecoverPointCGState.MIXED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.PAUSED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.STOPPED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            }
            // Fill in the Copy information
            if (settings.getGroupCopiesSettings() == null) {
                continue;
            }
            Map<String, String> copyUIDToNameMap = new HashMap<String, String>();
            Map<String, String> copyNameToRoleMap = new HashMap<String, String>();
            // used to set the copy uid on the rset volume when adding rsets
            Set<String> productionCopiesUID = new HashSet<String>();
            // Retrieve all RP copies for this CG
            for (ConsistencyGroupCopySettings copySettings : settings.getGroupCopiesSettings()) {
                GetCopyResponse copy = new GetCopyResponse();
                copy.setName(copySettings.getName());
                String copyID = copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + copySettings.getCopyUID().getGlobalCopyUID().getCopyUID();
                copyUIDToNameMap.put(copyID, copySettings.getName());
                for (ConsistencyGroupCopyState copyState : state.getGroupCopiesStates()) {
                    if (!RecoverPointUtils.copiesEqual(copySettings.getCopyUID(), copyState.getCopyUID())) {
                        continue;
                    }
                    // Get the access image and enabled information
                    copy.setAccessState(copyState.getStorageAccessState().toString());
                    copy.setAccessedImage(copyState.getAccessedImage() != null ? copyState.getAccessedImage().getDescription() : null);
                    copy.setEnabled(copyState.isEnabled());
                    copy.setActive(copyState.isActive());
                }
                // Set ID fields (these are immutable no matter if things are renamed)
                copy.setCgId(copySettings.getCopyUID().getGroupUID().getId());
                copy.setClusterId(copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId());
                copy.setCopyId(copySettings.getCopyUID().getGlobalCopyUID().getCopyUID());
                if (ConsistencyGroupCopyRole.ACTIVE.equals(copySettings.getRoleInfo().getRole()) || ConsistencyGroupCopyRole.TEMPORARY_ACTIVE.equals(copySettings.getRoleInfo().getRole())) {
                    productionCopiesUID.add(copyID);
                    copy.setProduction(true);
                    // Standby Production role is defined as: copy is production and copy is NOT active.
                    if (copy.isActive()) {
                        copy.setRole(GetCopyResponse.GetCopyRole.ACTIVE_PRODUCTION);
                    } else {
                        copy.setRole(GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION);
                    }
                } else if (ConsistencyGroupCopyRole.REPLICA.equals(copySettings.getRoleInfo().getRole())) {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.TARGET);
                } else {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.UNKNOWN);
                }
                // Add an entry for this copy name and its defined role
                copyNameToRoleMap.put(copy.getName(), copy.getRole().toString());
                if (copySettings.getJournal() == null || copySettings.getJournal().getJournalVolumes() == null) {
                    continue;
                }
                for (JournalVolumeSettings journal : copySettings.getJournal().getJournalVolumes()) {
                    GetVolumeResponse volume = new GetVolumeResponse();
                    volume.setRpCopyName(copySettings.getName());
                    volume.setInternalSiteName(clusterIdToInternalSiteNameMap.get(journal.getClusterUID().getId()));
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volume.setWwn(RecoverPointUtils.getGuidBufferAsString(journal.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (copy.getJournals() == null) {
                        copy.setJournals(new ArrayList<GetVolumeResponse>());
                    }
                    copy.getJournals().add(volume);
                }
                if (cgResp.getCopies() == null) {
                    cgResp.setCopies(new ArrayList<GetCopyResponse>());
                }
                cgResp.getCopies().add(copy);
            }
            // Retrieve all replication sets for this CG
            for (ReplicationSetSettings rsetSettings : settings.getReplicationSetsSettings()) {
                GetRSetResponse rset = new GetRSetResponse();
                rset.setName(rsetSettings.getReplicationSetName());
                if (rsetSettings.getVolumes() == null) {
                    continue;
                }
                for (UserVolumeSettings volume : rsetSettings.getVolumes()) {
                    GetVolumeResponse volResp = new GetVolumeResponse();
                    // Get the RP copy name, needed to match up sources to targets
                    String copyID = volume.getGroupCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + volume.getGroupCopyUID().getGlobalCopyUID().getCopyUID();
                    volResp.setRpCopyName(copyUIDToNameMap.get(copyID));
                    volResp.setInternalSiteName(clusterIdToInternalSiteNameMap.get(volume.getClusterUID().getId()));
                    if (productionCopiesUID.contains(copyID)) {
                        volResp.setProduction(true);
                        // volumes copy name to role mapping that was populated earlier.
                        if (GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION.toString().equalsIgnoreCase(copyNameToRoleMap.get(volResp.getRpCopyName()))) {
                            volResp.setProductionStandby(true);
                        }
                    } else {
                        volResp.setProduction(false);
                    }
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volResp.setWwn(RecoverPointUtils.getGuidBufferAsString(volume.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (rset.getVolumes() == null) {
                        rset.setVolumes(new ArrayList<GetVolumeResponse>());
                    }
                    rset.getVolumes().add(volResp);
                }
                if (cgResp.getRsets() == null) {
                    cgResp.setRsets(new ArrayList<GetRSetResponse>());
                }
                cgResp.getRsets().add(rset);
            }
            cgs.add(cgResp);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.failedToLookupConsistencyGroups(getCause(e));
    }
    return cgs;
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) GetCopyResponse(com.emc.storageos.recoverpoint.responses.GetCopyResponse) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) GetRSetResponse(com.emc.storageos.recoverpoint.responses.GetRSetResponse) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet) JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) GetVolumeResponse(com.emc.storageos.recoverpoint.responses.GetVolumeResponse) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) 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 ConsistencyGroupState

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

the class RecoverPointClient method getCGState.

/**
 * Return the state of a consistency group.
 *
 * @param cgUID - CG identifier
 *
 * @return the state of the CG
 *
 * @throws RecoverPointException
 */
private RecoverPointCGState getCGState(ConsistencyGroupUID cgUID) throws RecoverPointException {
    ConsistencyGroupSettings cgSettings = null;
    ConsistencyGroupState cgState = null;
    try {
        cgSettings = functionalAPI.getGroupSettings(cgUID);
        cgState = functionalAPI.getGroupState(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    } catch (FunctionalAPIInternalError_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    }
    if (!cgSettings.isEnabled()) {
        return RecoverPointCGState.STOPPED;
    }
    // First check for disabled copies
    boolean someCopiesEnabled = false;
    boolean someCopiesDisabled = false;
    for (ConsistencyGroupCopyState cgCopyState : cgState.getGroupCopiesStates()) {
        if (cgCopyState.isEnabled()) {
            someCopiesEnabled = true;
        } else {
            someCopiesDisabled = true;
        }
    }
    if (someCopiesDisabled && !someCopiesEnabled) {
        // All copies are disabled
        return RecoverPointCGState.STOPPED;
    }
    // Now check to see if all the copies are paused
    boolean someCopiesPaused = false;
    boolean someCopiesNotPaused = false;
    List<ConsistencyGroupLinkState> cgLinkStateList;
    try {
        cgLinkStateList = functionalAPI.getGroupState(cgUID).getLinksStates();
    } catch (FunctionalAPIActionFailedException_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    } catch (FunctionalAPIInternalError_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    }
    for (ConsistencyGroupLinkState cgLinkState : cgLinkStateList) {
        // OK, this is our link that we just restored. Check the link state to see if it is active
        if (PipeState.ACTIVE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_IDLE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_SHIPPING.equals(cgLinkState.getPipeState()) || PipeState.STAND_BY.equals(cgLinkState.getPipeState())) {
            someCopiesNotPaused = true;
        } else {
            someCopiesPaused = true;
        }
    }
    if (someCopiesPaused && !someCopiesNotPaused) {
        // All copies are paused
        return RecoverPointCGState.PAUSED;
    }
    if (someCopiesPaused || someCopiesDisabled) {
        return RecoverPointCGState.MIXED;
    }
    return RecoverPointCGState.READY;
}
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) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 8 with ConsistencyGroupState

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

the class RecoverPointClient method getReplicationSet.

/**
 * Get the replication set information associated with this volume. This is important when assembling a workflow to
 * recreate the replication set for the purpose of expanding volumes.
 *
 * Steps are as follows:
 * This method: Get the state information associated with the replication set
 * Delete method below: Delete the replication set
 * RP Controller: Expand volumes
 * Recreate method below: Perform a rescan_san
 * Recreate method below: Create the replication set
 *
 * @param RecoverPointVolumeProtectionInfo volume - Volume info for the CG to remove the replication set from
 * @return void
 *
 * @throws RecoverPointException
 */
public RecreateReplicationSetRequestParams getReplicationSet(RecoverPointVolumeProtectionInfo volume) throws RecoverPointException {
    ReplicationSetSettings rsetSettings = null;
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ReplicationSetUID repSetUID = new ReplicationSetUID();
        repSetUID.setId(volume.getRpVolumeRSetID());
        rsetSettings = getReplicationSetSettings(functionalAPI, rsetSettings, cgID, repSetUID);
        if (rsetSettings == null) {
            throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN());
        }
        RecreateReplicationSetRequestParams response = new RecreateReplicationSetRequestParams();
        response.setCgName(volume.getRpProtectionName());
        response.setName(rsetSettings.getReplicationSetName());
        response.setConsistencyGroupUID(cgID);
        response.setVolumes(new ArrayList<CreateRSetVolumeParams>());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        // Get the standby production copy (if one exists). In the case of MetroPoint,
        // we must ignore the standby copy device when getting the replication set. Including
        // the standby copy during replication set re-creation will throw an exception
        // because it has the same device ID as the active copy device.
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        for (UserVolumeSettings volumeSettings : rsetSettings.getVolumes()) {
            if (standbyProdCopy != null && RecoverPointUtils.copiesEqual(volumeSettings.getGroupCopyUID(), standbyProdCopy)) {
                // This is the standby production copy so ignore it.
                String standyCopyName = functionalAPI.getGroupCopyName(volumeSettings.getGroupCopyUID());
                logger.info(String.format("Ignoring volume %s at standby copy %s to avoid duplicate device IDs in replication set reconstruction for MetroPoint.", volumeSettings.getVolumeInfo().getVolumeName(), standyCopyName));
                continue;
            }
            CreateRSetVolumeParams volumeParams = new CreateRSetVolumeParams();
            volumeParams.setDeviceUID(volumeSettings.getVolumeInfo().getVolumeID());
            volumeParams.setConsistencyGroupCopyUID(volumeSettings.getGroupCopyUID());
            response.getVolumes().add(volumeParams);
        }
        return response;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    }
}
Also used : UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) RecreateReplicationSetRequestParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) CreateRSetVolumeParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams.CreateRSetVolumeParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ReplicationSetUID(com.emc.fapiclient.ws.ReplicationSetUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 9 with ConsistencyGroupState

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

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

Aggregations

ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)11 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)9 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)8 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)5 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)5 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)4 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)4 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)3 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 JournalVolumeSettings (com.emc.fapiclient.ws.JournalVolumeSettings)2 PipeState (com.emc.fapiclient.ws.PipeState)2 RecoverPointTimeStamp (com.emc.fapiclient.ws.RecoverPointTimeStamp)2 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ConsistencyGroupCopyJournal (com.emc.fapiclient.ws.ConsistencyGroupCopyJournal)1 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)1