Search in sources :

Example 16 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method getCopyState.

/**
 * Verify that a copy is capable of being enabled.
 *
 * @param impl - RP handle
 * @param copyId - CG Copy, contains CG
 * @param cgCopyName - copy name
 * @param cgName - CG name
 * @throws RecoverPointException
 */
public ConsistencyGroupCopyState getCopyState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyId, String cgCopyName, String cgName) throws RecoverPointException {
    try {
        ConsistencyGroupUID groupUID = copyId.getGroupUID();
        ConsistencyGroupState groupState;
        List<ConsistencyGroupCopyState> cgCopyStateList;
        groupState = impl.getGroupState(groupUID);
        cgCopyStateList = groupState.getGroupCopiesStates();
        for (ConsistencyGroupCopyState cgCopyState : cgCopyStateList) {
            if (RecoverPointUtils.copiesEqual(cgCopyState.getCopyUID(), copyId)) {
                return cgCopyState;
            }
        }
        return null;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, 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) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 17 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method enableCGCopyDirectAcess.

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

Example 18 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointImageManagementUtils method isSnapShotTechnologyEnabled.

/**
 * Determines if the specified consistency group is using snapshot technology
 * Returns true if the RP source copy is using snapshot technology, false otherwise
 *
 * @param impl the FAPI reference.
 * @param cgCopyUID the copy to be set as the production copy.
 * @throws RecoverPointException
 * @return boolean indicating if snapshot technology is being used
 */
private static boolean isSnapShotTechnologyEnabled(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID) throws RecoverPointException {
    String cgName = "unknown";
    try {
        cgName = impl.getGroupName(cgUID);
        ConsistencyGroupSettings groupSettings = impl.getGroupSettings(cgUID);
        List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
        for (ConsistencyGroupCopySettings copySetting : copySettings) {
            if (copySetting.getRoleInfo().getRole().equals(ConsistencyGroupCopyRole.ACTIVE) && copySetting.getPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() != null && copySetting.getPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() > 0) {
                logger.info("Setting link state for snapshot technology.");
                return true;
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    return false;
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings)

Example 19 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointUtils method getArraysForCluster.

/**
 * Get all of the arrays associated with a cluster
 *
 * @param impl endpoint interface
 * @param clusterUID cluster ID
 * @return set of storage systems
 * @throws RecoverPointException
 */
public static Set<String> getArraysForCluster(FunctionalAPIImpl impl, ClusterUID clusterUID) throws RecoverPointException {
    Set<String> returnArrays = new HashSet<>();
    try {
        logger.info("Finding arrays associated with RP cluster: " + clusterUID.getId());
        // Get the arrays that are configured as splitters.
        ClusterSplittersSettings splitterSettings = impl.getSplittersSettingsFromCluster(clusterUID);
        if (splitterSettings != null && splitterSettings.getSplittersSettings() != null) {
            for (SplitterSettings splitterSetting : splitterSettings.getSplittersSettings()) {
                // The splitter name will arrive as:
                // VPLEX: FNM0123456789
                // VNX: APM0123467890-A
                // VMAX: SYMM-01947656483
                // In all cases, we need to distill that into a serial number.
                // 
                // NOTE: What would be ideal is to take the SplitterSetting.getArrayID() and get back
                // native array information. I could not find that method, so I had to resort to
                // this for now. It does work, but it's not ideal. WJEIV
                Pattern myPattern = Pattern.compile("[A-Z,a-z,0-9]*");
                Matcher m = myPattern.matcher(splitterSetting.getSplitterName());
                while (m.find()) {
                    String s = m.group(0);
                    // We get around this by finding the third group in the pattern.
                    if (s.equals("SYMM")) {
                        // Iterate to the "-"
                        m.find();
                        // Iterate to the serial number
                        m.find();
                        s = m.group(0);
                    }
                    returnArrays.add(s);
                    logger.info("Found array name: " + s);
                    break;
                }
            }
        }
        return returnArrays;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingArrays(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingArrays(e);
    }
}
Also used : Pattern(java.util.regex.Pattern) SplitterSettings(com.emc.fapiclient.ws.SplitterSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) Matcher(java.util.regex.Matcher) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ClusterSplittersSettings(com.emc.fapiclient.ws.ClusterSplittersSettings) HashSet(java.util.HashSet)

Example 20 with FunctionalAPIActionFailedException_Exception

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

the class RecoverPointUtils method getPreferredRPAForNewCG.

/**
 * Returns the preferred RPA number to use as the primary RPA for a new
 * consistency group. The preferred RPA is determined by examining the
 * current throughput for all of the passed in cluster's RPAs and selecting
 * the RPA that is currently handling the least amount of throughput.
 *
 * @param impl - the established connection to an appliance
 * @param clusterUID - corresponding to the site that we are trying to determine the preferred RPA for.
 * @return RpaUID - object with the preferred RPA number
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 */
public static RpaUID getPreferredRPAForNewCG(FunctionalAPIImpl impl, ClusterUID clusterUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    RpaUID preferredRPA = new RpaUID();
    // set the cluster UID to the value being passed
    preferredRPA.setClusterUID(clusterUID);
    // default the rpa to 1
    preferredRPA.setRpaNumber(1);
    try {
        SystemStatistics systemStatistics = impl.getSystemStatistics();
        List<RpaStatistics> rpaStatisticsList = systemStatistics.getRpaStatistics();
        Long smallestThroughput = Long.valueOf(0);
        Long currenThroughput = Long.valueOf(0);
        for (RpaStatistics rpaStatistics : rpaStatisticsList) {
            if (rpaStatistics.getRpaUID().getClusterUID().getId() == clusterUID.getId()) {
                currenThroughput = Long.valueOf(0);
                logger.info("Looking at current throughput for RPA " + rpaStatistics.getRpaUID().getRpaNumber() + " on cluster " + rpaStatistics.getRpaUID().getClusterUID().getId());
                TrafficStatistics trafficStatistics = rpaStatistics.getTraffic();
                InOutThroughputStatistics throughput = trafficStatistics.getApplicationThroughputStatistics();
                List<ConnectionOutThroughput> out = throughput.getConnectionsOutThroughputs();
                for (ConnectionOutThroughput a : out) {
                    logger.info("RPA " + rpaStatistics.getRpaUID().getRpaNumber() + " throughput to cluster " + a.getCluster().getId() + ": " + a.getOutThroughput() + " bytes/sec");
                    currenThroughput += a.getOutThroughput();
                }
                if (smallestThroughput.longValue() == 0) {
                    smallestThroughput = currenThroughput;
                }
                logger.info("Total throughput for RPA " + rpaStatistics.getRpaUID().getRpaNumber() + ": " + currenThroughput.toString() + " bytes/sec");
                if (currenThroughput.compareTo(smallestThroughput) <= 0) {
                    smallestThroughput = currenThroughput;
                    preferredRPA.setRpaNumber(rpaStatistics.getRpaUID().getRpaNumber());
                }
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
        logger.info("Encountered error determining the preferred RPA, defaulting to RPA 1");
        preferredRPA.setRpaNumber(1);
        return preferredRPA;
    }
    logger.info("Selected RPA " + preferredRPA.getRpaNumber() + " of cluster " + preferredRPA.getClusterUID().getId() + " for the new consistency group");
    return preferredRPA;
}
Also used : RpaStatistics(com.emc.fapiclient.ws.RpaStatistics) TrafficStatistics(com.emc.fapiclient.ws.TrafficStatistics) SystemStatistics(com.emc.fapiclient.ws.SystemStatistics) ConnectionOutThroughput(com.emc.fapiclient.ws.ConnectionOutThroughput) RpaUID(com.emc.fapiclient.ws.RpaUID) InOutThroughputStatistics(com.emc.fapiclient.ws.InOutThroughputStatistics) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

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