Search in sources :

Example 1 with ClusterConsistencyGroupWrapper

use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.

the class AbstractConsistencyGroupManager method getClusterConsistencyGroupVolumes.

/**
 * Based on a list of VPlex volumes and a ViPR consistency group, this method determines
 * the corresponding VPlex cluster names and VPlex consistency group names.
 *
 * @param vplexVolumeURIs The VPlex virtual volumes to analyze
 * @param cgName The ViPR BlockConsistencyGroup name
 * @return A mapping of VPlex cluster/consistency groups to their associated volumes
 * @throws Exception
 */
protected Map<ClusterConsistencyGroupWrapper, List<URI>> getClusterConsistencyGroupVolumes(List<URI> vplexVolumeURIs, BlockConsistencyGroup cg) throws Exception {
    Map<ClusterConsistencyGroupWrapper, List<URI>> clusterConsistencyGroups = new HashMap<ClusterConsistencyGroupWrapper, List<URI>>();
    for (URI vplexVolumeURI : vplexVolumeURIs) {
        Volume vplexVolume = getDataObject(Volume.class, vplexVolumeURI, dbClient);
        addVolumeToClusterConsistencyGroup(vplexVolume, clusterConsistencyGroups, cg);
    }
    return clusterConsistencyGroups;
}
Also used : ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) URI(java.net.URI)

Example 2 with ClusterConsistencyGroupWrapper

use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.

the class AbstractConsistencyGroupManager method addVolumeToCg.

@Override
public void addVolumeToCg(URI cgURI, Volume vplexVolume, VPlexApiClient client, boolean addToViPRCg) throws Exception {
    BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
    ClusterConsistencyGroupWrapper clusterCgWrapper = this.getClusterConsistencyGroup(vplexVolume, cg);
    log.info("Adding volumes to consistency group: " + clusterCgWrapper.getCgName());
    // Add the volume from the CG.
    client.addVolumesToConsistencyGroup(clusterCgWrapper.getCgName(), Arrays.asList(vplexVolume.getDeviceLabel()));
    if (addToViPRCg) {
        vplexVolume.setConsistencyGroup(cgURI);
        dbClient.updateAndReindexObject(vplexVolume);
    }
}
Also used : ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 3 with ClusterConsistencyGroupWrapper

use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.

the class AbstractConsistencyGroupManager method removeVolumeFromCg.

@Override
public void removeVolumeFromCg(URI cgURI, Volume vplexVolume, VPlexApiClient client, boolean removeFromViPRCg) throws Exception {
    BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
    ClusterConsistencyGroupWrapper clusterCgWrapper = this.getClusterConsistencyGroup(vplexVolume, cg);
    log.info("Removing volumes from consistency group: " + clusterCgWrapper.getCgName());
    // Remove the volumes from the CG.
    client.removeVolumesFromConsistencyGroup(Arrays.asList(vplexVolume.getDeviceLabel()), clusterCgWrapper.getCgName(), false);
    if (removeFromViPRCg) {
        vplexVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
        dbClient.updateAndReindexObject(vplexVolume);
    }
}
Also used : ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 4 with ClusterConsistencyGroupWrapper

use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.

the class AbstractConsistencyGroupManager method getVplexCgName.

/**
 * Gets the VPlex consistency group name that corresponds to the volume
 * and BlockConsistencyGroup.
 *
 * @param volume The virtual volume used to determine cluster configuration.
 * @param cgURI The BlockConsistencyGroup id.
 * @return The VPlex consistency group name
 * @throws Exception
 */
protected String getVplexCgName(Volume volume, URI cgURI) throws Exception {
    BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
    ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(volume, cg);
    return clusterConsistencyGroup.getCgName();
}
Also used : ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 5 with ClusterConsistencyGroupWrapper

use of com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper in project coprhd-controller by CoprHD.

the class RPVplexConsistencyGroupManager method getClusterConsistencyGroup.

/**
 * Maps a VPlex cluster/consistency group to its volumes.
 *
 * @param vplexVolume The virtual volume from which to obtain the VPlex cluster.
 * @param clusterConsistencyGroupVolumes The map to store cluster/cg/volume relationships.
 * @param cgName The VPlex consistency group name.
 * @throws Exception
 */
@Override
public ClusterConsistencyGroupWrapper getClusterConsistencyGroup(Volume vplexVolume, BlockConsistencyGroup cg) throws Exception {
    ClusterConsistencyGroupWrapper clusterConsistencyGroup = new ClusterConsistencyGroupWrapper();
    String vplexCgName = null;
    // Find the correct VPLEX cluster for this volume
    String vplexCluster = VPlexControllerUtils.getVPlexClusterName(dbClient, vplexVolume);
    // Determine if the volume is distributed
    boolean distributed = false;
    StringSet assocVolumes = vplexVolume.getAssociatedVolumes();
    // Associated volume for the consistency group cannot be null, indicates back-end volumes are not ingested.
    if (vplexVolume.getAssociatedVolumes() != null && !vplexVolume.getAssociatedVolumes().isEmpty()) {
        if (assocVolumes.size() > 1) {
            distributed = true;
        }
    } else {
        String reason = "Associated volume is empty";
        throw VPlexApiException.exceptions.emptyAssociatedVolumes(vplexVolume.getDeviceLabel(), vplexCluster, reason);
    }
    // Keep a reference to the VPLEX
    URI vplexURI = vplexVolume.getStorageController();
    log.info(String.format("Find correct VPLEX CG for VPLEX %s volume [%s](%s) at cluster [%s] on VPLEX (%s)", (distributed ? "distribitued" : "local"), vplexVolume.getLabel(), vplexVolume.getId(), vplexCluster, vplexURI));
    // line up the CG name from the ViPR CG to the VPLEX CGs.
    if (cg.created(vplexURI)) {
        log.info("CG already exists on VPLEX, but we need to figure out the correct one to use...");
        List<String> validVPlexCGsForCluster = new ArrayList<String>();
        // Extract all the CG names for the VPLEX
        // These names are in the format of: cluster-1:cgName or cluster-2:cgName
        StringSet cgNames = cg.getSystemConsistencyGroups().get(vplexURI.toString());
        // Iterate over the names to line up with the cluster
        Iterator<String> cgNamesIter = cgNames.iterator();
        while (cgNamesIter.hasNext()) {
            String clusterCgName = cgNamesIter.next();
            String cluster = BlockConsistencyGroupUtils.fetchClusterName(clusterCgName);
            String cgName = BlockConsistencyGroupUtils.fetchCgName(clusterCgName);
            // We will narrow this down afterwards for distributed.
            if (vplexCluster.equals(cluster) || distributed) {
                validVPlexCGsForCluster.add(cgName);
            }
        }
        // Get the API client.
        StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, dbClient);
        VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
        log.info("Got VPLEX API client.");
        // This is not ideal but we need to call the VPlex client to fetch all consistency
        // groups so we can find the exact one we are looking for.
        List<VPlexConsistencyGroupInfo> vplexCGs = client.getConsistencyGroups();
        log.info("Iterating over returned VPLEX CGs to find the one we should use...");
        for (VPlexConsistencyGroupInfo vplexCG : vplexCGs) {
            boolean cgNameFound = validVPlexCGsForCluster.contains(vplexCG.getName());
            boolean volumeFound = vplexCG.getVirtualVolumes().contains(vplexVolume.getDeviceLabel());
            // either way it's valid.
            if (cgNameFound || volumeFound) {
                // Determine if the VPLEX CG is distributed.
                // NOTE: VPlexConsistencyGroupInfo.isDistributed() is not returning
                // the correct information. This is probably due to teh fact that
                // visibleClusters is not being returned in the response.
                // Instead we are checking getStorageAtClusters().size().
                boolean vplexCGIsDistributed = (vplexCG.getStorageAtClusters().size() > 1);
                if ((distributed && vplexCGIsDistributed) || (!distributed && !vplexCGIsDistributed)) {
                    log.info(String.format("Found correct VPLEX CG: %s", vplexCG.getName()));
                    vplexCgName = vplexCG.getName();
                    break;
                }
            }
        }
    }
    // The format for VPLEX local: cgName-vplexCluster
    if (vplexCgName == null) {
        // If we do not have a VPLEX CG name it's time to create one.
        if (distributed) {
            // Add '-dist' to the end of the CG name for distributed consistency groups.
            vplexCgName = cg.getLabel() + "-dist";
        } else {
            vplexCgName = cg.getLabel() + "-" + vplexCluster;
        }
        log.info(String.format("There was no existing VPLEX CG, created CG name: %s", vplexCgName));
    }
    clusterConsistencyGroup.setClusterName(vplexCluster);
    clusterConsistencyGroup.setCgName(vplexCgName);
    clusterConsistencyGroup.setDistributed(distributed);
    return clusterConsistencyGroup;
}
Also used : ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) VPlexConsistencyGroupInfo(com.emc.storageos.vplex.api.VPlexConsistencyGroupInfo) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ClusterConsistencyGroupWrapper (com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper)14 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)8 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)7 Volume (com.emc.storageos.db.client.model.Volume)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)6 WorkflowException (com.emc.storageos.workflow.WorkflowException)6 URI (java.net.URI)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)5 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)5 ArrayList (java.util.ArrayList)5 StringSet (com.emc.storageos.db.client.model.StringSet)4 HashMap (java.util.HashMap)2 List (java.util.List)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 VPlexConsistencyGroupInfo (com.emc.storageos.vplex.api.VPlexConsistencyGroupInfo)1