Search in sources :

Example 1 with SplitterSettings

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

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

the class RecoverPointUtils method getSplittersToAttachToForVolume.

/**
 * Finds the splitter(s) to attach a volume to (if any need to be attached).
 *
 * @param impl - handle for FAPI
 * @param ClusterUID - site for the volume
 * @param volume - volume ID we are looking for
 * @return - Set<SplitterUID>
 */
private static Set<SplitterUID> getSplittersToAttachToForVolume(FunctionalAPIImpl impl, ClusterUID ClusterUID, DeviceUID volume) throws RecoverPointException {
    Set<SplitterUID> returnSplitters = new HashSet<SplitterUID>();
    try {
        logger.info("Finding splitters with unattached volumes");
        List<SplitterUID> splittersWithUnattachedVols = impl.getAvailableSplittersToAttachToVolume(ClusterUID, volume);
        for (SplitterUID splitterUID : splittersWithUnattachedVols) {
            SplitterSettings splitterSettings = impl.getSplitterSettings(splitterUID);
            List<DeviceUID> unattachedVolumes = impl.getAvailableVolumesToAttachToSplitter(splitterUID, true);
            if (!unattachedVolumes.isEmpty()) {
                for (DeviceUID unattachedVolume : unattachedVolumes) {
                    if (unattachedVolume.getId() == volume.getId()) {
                        returnSplitters.add(splitterSettings.getSplitterUID());
                    }
                }
            }
        }
        return returnSplitters;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSplittersVolume(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSplittersVolume(e);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SplitterSettings(com.emc.fapiclient.ws.SplitterSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) DeviceUID(com.emc.fapiclient.ws.DeviceUID) HashSet(java.util.HashSet)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 SplitterSettings (com.emc.fapiclient.ws.SplitterSettings)2 HashSet (java.util.HashSet)2 ClusterSplittersSettings (com.emc.fapiclient.ws.ClusterSplittersSettings)1 DeviceUID (com.emc.fapiclient.ws.DeviceUID)1 SplitterUID (com.emc.fapiclient.ws.SplitterUID)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1