Search in sources :

Example 1 with FunctionalAPIInternalError_Exception

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

the class RecoverPointClient method updateConsistencyGroupPolicy.

/**
 * Updates the entire consistency group policy. Meaning the link policy for each link
 * will be changed to the same policy.
 *
 * @param policyParam the update policy param
 */
public void updateConsistencyGroupPolicy(UpdateCGPolicyParams policyParam) {
    if (policyParam == null) {
        logger.warn("Unable to update policy for CG. The update paramaters are invalid.");
        return;
    }
    if (policyParam.getPolicyParams() == null) {
        logger.warn("Unable to update policy for CG. The update paramaters are missing.");
        return;
    }
    if (policyParam.getPolicyParams().getCopyMode() == null) {
        logger.warn("Unable to update CG policy copy mode. The copy mode paramaters is missing.");
        return;
    }
    try {
        String copyMode = policyParam.getPolicyParams().getCopyMode();
        ConsistencyGroupUID cgUID = getConsistencyGroupUID(policyParam.getCgName());
        FullConsistencyGroupPolicy cgPolicy = functionalAPI.getFullConsistencyGroupPolicy(cgUID);
        List<FullConsistencyGroupLinkPolicy> linkPolicies = cgPolicy.getLinksPolicies();
        for (FullConsistencyGroupLinkPolicy linkPolicy : linkPolicies) {
            ConsistencyGroupLinkPolicy cgLinkPolicy = linkPolicy.getLinkPolicy();
            LinkProtectionPolicy linkProtectionPolicy = cgLinkPolicy.getProtectionPolicy();
            if (copyMode != null) {
                ProtectionMode protectionMode = ProtectionMode.valueOf(copyMode);
                if (protectionMode != null) {
                    linkProtectionPolicy.setProtectionType(protectionMode);
                    cgLinkPolicy.setProtectionPolicy(linkProtectionPolicy);
                }
            }
        }
        logger.info(String.format("Setting protection mode for CG links to %s, for CG %s", copyMode, policyParam.getCgName()));
        functionalAPI.setFullConsistencyGroupPolicy(cgPolicy);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    }
}
Also used : FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) LinkProtectionPolicy(com.emc.fapiclient.ws.LinkProtectionPolicy) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) 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) ProtectionMode(com.emc.fapiclient.ws.ProtectionMode)

Example 2 with FunctionalAPIInternalError_Exception

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

the class RecoverPointClient method recreateReplicationSets.

/**
 * Perform Step 2 of expanding a volume, Recreate a replication set that was previously removed.
 *
 * @param volume volume base of replication set
 * @param rsetSettings replication set information used to create replication set
 * @throws RecoverPointException
 */
public void recreateReplicationSets(Map<String, RecreateReplicationSetRequestParams> rsetParams) throws RecoverPointException {
    if (rsetParams != null && !rsetParams.isEmpty()) {
        // Used to capture the volume WWNs associated with each replication set to recreate.
        List<String> volumeWWNs = new ArrayList<String>();
        try {
            // Get the CG ID from the first element in the list. All elements will share
            // the same CG ID.
            RecreateReplicationSetRequestParams param = rsetParams.values().iterator().next();
            ConsistencyGroupUID cgID = param.getConsistencyGroupUID();
            // Rescan the SAN
            functionalAPI.rescanSANVolumesInAllClusters(true);
            ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
            ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
            cgActivationSettings.setEnable(true);
            cgActivationSettings.setStartTransfer(true);
            cgSettingsParam.setActivationParams(cgActivationSettings);
            cgSettingsParam.setGroupUID(cgID);
            for (Entry<String, RecreateReplicationSetRequestParams> entry : rsetParams.entrySet()) {
                RecreateReplicationSetRequestParams rsetParam = entry.getValue();
                // Create replication set
                logger.info("Adding replication set: " + rsetParam.getName());
                ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
                repSetSettings.setName(rsetParam.getName());
                repSetSettings.setShouldAttachAsClean(false);
                for (CreateRSetVolumeParams volume : rsetParam.getVolumes()) {
                    UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
                    volSettings.setNewVolumeID(volume.getDeviceUID());
                    volSettings.setCopyUID(volume.getConsistencyGroupCopyUID());
                    volSettings.getCopyUID().setGroupUID(cgID);
                    repSetSettings.getVolumesChanges().add(volSettings);
                }
                cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
                volumeWWNs.add(entry.getKey());
            }
            // Add the replication set
            functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
            logger.info("Checking for volumes unattached to splitters");
            RecoverPointUtils.verifyCGVolumesAttachedToSplitter(functionalAPI, cgID);
            RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
            logger.info("Waiting for links to become active for CG ");
            // Wait for the active state or paused state. If a copy is in direct access mode, the link
            // will be paused but it's still a valid state.
            rpiMgmt.waitForCGLinkState(functionalAPI, cgID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgID), PipeState.PAUSED);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
        }
    }
}
Also used : ReplicationSetSettingsChangesParam(com.emc.fapiclient.ws.ReplicationSetSettingsChangesParam) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) UserVolumeSettingsChangesParam(com.emc.fapiclient.ws.UserVolumeSettingsChangesParam) ArrayList(java.util.ArrayList) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RecreateReplicationSetRequestParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams) CreateRSetVolumeParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams.CreateRSetVolumeParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ActivationSettingsChangesParams(com.emc.fapiclient.ws.ActivationSettingsChangesParams)

Example 3 with FunctionalAPIInternalError_Exception

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

the class RecoverPointClient method getProtectionInfoForVolume.

/**
 * The getProtectionInfoForVolume method takes the WWN, and looks for it in the RP site protection environment.
 * If it finds the WWN as a member of a consistency group, it fills in the information, and returns it to the caller.
 * If it does not find the WWN as a member of a consistency group, it returns null
 *
 * @param String volumeWWN - The WWN being checked for RecoverPoint protection
 *
 * @return RecoverPointVolumeProtectionInfo - description of protection information about the WWN, or null if not protected in CG
 *
 * @throws RecoverPointException
 */
public RecoverPointVolumeProtectionInfo getProtectionInfoForVolume(String volumeWWN) throws RecoverPointException {
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    try {
        // logger.info("getProtectionInfoForVolume called for: " + volumeWWN);
        protectionInfo = new RecoverPointVolumeProtectionInfo();
        List<ConsistencyGroupSettings> cgsSettings = functionalAPI.getAllGroupsSettings();
        for (ConsistencyGroupSettings cgSettings : cgsSettings) {
            // See if it is a production source, or an RP target
            for (ReplicationSetSettings rsSettings : cgSettings.getReplicationSetsSettings()) {
                for (UserVolumeSettings uvSettings : rsSettings.getVolumes()) {
                    if (matchesVolumeWWN(uvSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = uvSettings.getGroupCopyUID().getGroupUID();
                        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(uvSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(uvSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpCopyName(cgCopyName);
                        protectionInfo.setRpSiteName(getRecoverPointClusterName(uvSettings.getClusterUID()));
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(uvSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeRSetID(rsSettings.getReplicationSetUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(uvSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            if (RecoverPointUtils.isStandbyProductionCopy(uvSettings.getGroupCopyUID(), state, productionCopiesUIDs)) {
                                // In the case of MetroPoint, we will have 2 production copies for the same volume (active and standby).
                                // We want to always match on the active production copy. If this is a MetroPoint CG, skip over the
                                // standby production copy.
                                logger.info(String.format("Found production volume %s on copy %s.  Skipping because it is not the active production copy.", volumeWWN, cgCopyName));
                                continue;
                            }
                            logger.info("Production volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE);
                        } else {
                            logger.info("Target volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET);
                        }
                        return protectionInfo;
                    }
                }
            }
            // See if it is a journal volume
            for (ConsistencyGroupCopySettings cgCopySettings : cgSettings.getGroupCopiesSettings()) {
                ConsistencyGroupCopyJournal cgJournal = cgCopySettings.getJournal();
                List<JournalVolumeSettings> journalVolumeSettingsList = cgJournal.getJournalVolumes();
                for (JournalVolumeSettings journalVolumeSettings : journalVolumeSettingsList) {
                    if (matchesVolumeWWN(journalVolumeSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = journalVolumeSettings.getGroupCopyUID().getGroupUID();
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(journalVolumeSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(journalVolumeSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(journalVolumeSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(journalVolumeSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            logger.info("Production journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.SOURCE_JOURNAL);
                        } else {
                            logger.info("Target journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.TARGET_JOURNAL);
                        }
                        return protectionInfo;
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    }
    throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN);
}
Also used : JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) 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) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupCopyJournal(com.emc.fapiclient.ws.ConsistencyGroupCopyJournal) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 4 with FunctionalAPIInternalError_Exception

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

the class RecoverPointClient method swapCopy.

/**
 * Perform a swap to the consistency group copy specified by the input request params.
 *
 * @param copyParams the volume info for the CG to perform a swap to.
 *
 * @return void
 *
 * @throws RecoverPointException
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
    try {
        logger.info("Swap copy to current or most recent image");
        // Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
        RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
        ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
        ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
        if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
            // Enable image access to the latest snapshot if copy image access isn't already enabled.
            failoverCopy(copyParams);
        }
        ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
        // data replication. Otherwise, we need to perform a failover.
        if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
            logger.info("Swap copy is a production copy with role 'Target at Production'.  Resuming production to complete the swap.");
            functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
        } else {
            // Perform the failover
            imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
        }
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
        throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 5 with FunctionalAPIInternalError_Exception

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

the class RecoverPointClient method doesStandbyProdCopyExist.

/**
 * Determines if the consistency group associated with the volume protection info contains
 * a standby production copy.
 *
 * @param volume the volume protection information
 * @return true if the standby production copy exists, false otherwise
 */
public boolean doesStandbyProdCopyExist(RecoverPointVolumeProtectionInfo volume) {
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        if (standbyProdCopy != null) {
            String standbyProdCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
            logger.info(String.format("Determined that standby production copy %s exists in CG %s.", standbyProdCopyName, volume.getRpProtectionName()));
            return true;
        }
        logger.info(String.format("Determined that no standby production copy exists in CG %s.", volume.getRpProtectionName()));
        return false;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) 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