Search in sources :

Example 1 with SplitterUID

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

the class RecoverPointUtils method verifyCGVolumesAttachedToSplitter.

/**
 * verify that the volumes in a consistency group are connected to a splitter
 *
 * @param impl - handle for FAPI
 * @param groupUID - consistency group to examine volumes on
 * @throws - RecoverPointException
 */
public static void verifyCGVolumesAttachedToSplitter(FunctionalAPIImpl impl, ConsistencyGroupUID groupUID) throws RecoverPointException {
    ConsistencyGroupSettings groupSettings;
    try {
        groupSettings = impl.getGroupSettings(groupUID);
        // Get the consistency group settings
        for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
            // Run over all replication sets
            for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
                logger.info("Volume : " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is of type " + userVolume.getVolumeType());
                if (userVolume.getAttachedSplitters().isEmpty()) {
                    String volumeWWN = RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false);
                    logger.warn("Volume " + volumeWWN + " is not attached to any splitters");
                    Set<SplitterUID> splittersToAttachTo = getSplittersToAttachToForVolume(impl, userVolume.getClusterUID(), userVolume.getVolumeInfo().getVolumeID());
                    for (SplitterUID splitterUID : splittersToAttachTo) {
                        SetVolumeParam volumeParam = new SetVolumeParam();
                        volumeParam.setShouldAttachAsClean(false);
                        volumeParam.setVolumeID(userVolume.getVolumeInfo().getVolumeID());
                        logger.info("Attaching volume " + volumeWWN + " to splitter" + impl.getSplitterName(splitterUID));
                        impl.attachVolumeToSplitter(splitterUID, volumeParam);
                    }
                } else {
                    for (SplitterUID splitterUID : userVolume.getAttachedSplitters()) {
                        logger.info("Volume " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is attached to splitter " + impl.getSplitterName(splitterUID));
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SetVolumeParam(com.emc.fapiclient.ws.SetVolumeParam) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 2 with SplitterUID

use of com.emc.fapiclient.ws.SplitterUID 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 SplitterUID (com.emc.fapiclient.ws.SplitterUID)2 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 DeviceUID (com.emc.fapiclient.ws.DeviceUID)1 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)1 SetVolumeParam (com.emc.fapiclient.ws.SetVolumeParam)1 SplitterSettings (com.emc.fapiclient.ws.SplitterSettings)1 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)1 HashSet (java.util.HashSet)1