Search in sources :

Example 1 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ControllerUtils method getMirrorReplicationGroupNames.

/**
 * Gets mirror replication group names from mirrors of all volumes in CG.
 */
public static Set<String> getMirrorReplicationGroupNames(List<Volume> volumes, DbClient dbClient) {
    Set<String> groupNames = new HashSet<String>();
    // check if replica of any of these volumes have replicationGroupInstance set
    for (Volume volume : volumes) {
        URIQueryResultList mirrorList = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volume.getId()), mirrorList);
        Iterator<URI> iter = mirrorList.iterator();
        while (iter.hasNext()) {
            URI mirrorID = iter.next();
            BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
            if (mirror != null && !mirror.getInactive() && NullColumnValueGetter.isNotNullValue(mirror.getReplicationGroupInstance())) {
                groupNames.add(mirror.getReplicationGroupInstance());
            }
        }
        if (!groupNames.isEmpty()) {
            // no need to check other CG members
            break;
        }
    }
    return groupNames;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 2 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ControllerUtils method getMirrorsPartOfReplicationGroup.

/**
 * Gets the mirrors part of a given replication group.
 */
public static List<BlockMirror> getMirrorsPartOfReplicationGroup(String replicationGroupInstance, DbClient dbClient) {
    List<BlockMirror> mirrors = new ArrayList<BlockMirror>();
    URIQueryResultList uriQueryResultList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getMirrorReplicationGroupInstanceConstraint(replicationGroupInstance), uriQueryResultList);
    Iterator<BlockMirror> mirrorIterator = dbClient.queryIterativeObjects(BlockMirror.class, uriQueryResultList);
    while (mirrorIterator.hasNext()) {
        BlockMirror mirror = mirrorIterator.next();
        if (mirror != null && !mirror.getInactive()) {
            mirrors.add(mirror);
        }
    }
    return mirrors;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ControllerUtils method checkCGHasGroupRelationship.

/**
 * Check if CG has any group relationship
 *
 * Note - on array side, if replica has been removed from replication group, but source volume has not been removed from CG yet,
 * the CG will not have group relationship until the source volume get removed from the CG.
 *
 * As a result, getting associator names cannot be used to check if CG has group relationship.
 */
public static boolean checkCGHasGroupRelationship(StorageSystem storage, URI cgURI, DbClient dbClient) {
    // get volumes part of this CG
    List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(cgURI, dbClient);
    boolean isVNX = storage.deviceIsType(Type.vnxblock);
    // check if replica of any of these volumes have replicationGroupInstance set
    for (Volume volume : volumes) {
        if (NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
            if (!isVNX) {
                // VNX doesn't have group clones/mirrors
                // clone
                URIQueryResultList cloneList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getAssociatedSourceVolumeConstraint(volume.getId()), cloneList);
                Iterator<URI> iter = cloneList.iterator();
                while (iter.hasNext()) {
                    URI cloneID = iter.next();
                    Volume clone = dbClient.queryObject(Volume.class, cloneID);
                    if (clone != null && !clone.getInactive()) {
                        return true;
                    }
                }
                // mirror
                URIQueryResultList mirrorList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volume.getId()), mirrorList);
                Iterator<URI> itr = mirrorList.iterator();
                while (itr.hasNext()) {
                    URI mirrorID = itr.next();
                    BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
                    if (mirror != null && !mirror.getInactive()) {
                        return true;
                    }
                }
            }
            // snapshot
            URIQueryResultList list = new URIQueryResultList();
            dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), list);
            Iterator<URI> it = list.iterator();
            while (it.hasNext()) {
                URI snapshotID = it.next();
                BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotID);
                if (snapshot != null && !snapshot.getInactive()) {
                    return true;
                }
            }
            // snapshot session
            if (storage.checkIfVmax3()) {
                URIQueryResultList sessionList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getBlockSnapshotSessionByConsistencyGroup(cgURI), sessionList);
                Iterator<URI> itr = sessionList.iterator();
                while (itr.hasNext()) {
                    URI sessionID = itr.next();
                    BlockSnapshotSession session = dbClient.queryObject(BlockSnapshotSession.class, sessionID);
                    if (session != null && !session.getInactive()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ControllerUtils method getAutoTieringPolicyName.

public static String getAutoTieringPolicyName(URI uri, DbClient dbClient) {
    String policyName = Constants.NONE;
    if (URIUtil.isType(uri, Volume.class)) {
        Volume volume = dbClient.queryObject(Volume.class, uri);
        URI policyURI = volume.getAutoTieringPolicyUri();
        if (!NullColumnValueGetter.isNullURI(policyURI)) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
            policyName = policy.getPolicyName();
        }
    } else if (URIUtil.isType(uri, BlockSnapshot.class)) {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, uri);
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, snapshot.getStorageController());
        if (storage.checkIfVmax3()) {
            Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
            URI policyURI = volume.getAutoTieringPolicyUri();
            if (!NullColumnValueGetter.isNullURI(policyURI)) {
                AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
                policyName = policy.getPolicyName();
            }
        }
    } else if (URIUtil.isType(uri, BlockMirror.class)) {
        BlockMirror mirror = dbClient.queryObject(BlockMirror.class, uri);
        if (!NullColumnValueGetter.isNullURI(mirror.getAutoTieringPolicyUri())) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, mirror.getAutoTieringPolicyUri());
            policyName = policy.getPolicyName();
        }
    }
    return policyName;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class AbstractBlockServiceApiImpl method addDescriptorsForMirrors.

/**
 * Given a list of VolumeDescriptors and a volume, adds the descriptors necessary
 * for any BlockMirrors on the volume.
 *
 * @param descriptors
 *            List<VolumeDescriptor>
 * @param volume
 */
protected void addDescriptorsForMirrors(List<VolumeDescriptor> descriptors, Volume volume) {
    if (volume.getMirrors() != null && volume.getMirrors().isEmpty() == false) {
        for (String mirrorId : volume.getMirrors()) {
            BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, URI.create(mirrorId));
            if (mirror != null && !mirror.getInactive()) {
                VolumeDescriptor mirrorDesc = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_MIRROR, volume.getStorageController(), URI.create(mirrorId), null, null);
                descriptors.add(mirrorDesc);
            }
        }
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockMirror(com.emc.storageos.db.client.model.BlockMirror)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9