Search in sources :

Example 81 with BlockMirror

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

the class HDSMirrorOperations method fractureSingleVolumeMirror.

/**
 * Split ShadowImage pair
 */
@Override
public void fractureSingleVolumeMirror(StorageSystem storage, URI mirror, Boolean sync, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("fractureSingleVolumeMirror started");
    try {
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        Volume sourceVolume = dbClient.queryObject(Volume.class, mirrorObj.getSource());
        hdsProtectionOperations.modifyShadowImagePair(storage, sourceVolume.getNativeId(), mirrorObj.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
        HDSJob syncjob = new HDSReplicationSyncJob(storage.getId(), sourceVolume.getNativeId(), mirrorObj.getNativeId(), ReplicationStatus.SPLIT, taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(syncjob);
        mirrorObj.setSyncState(SynchronizationState.FRACTURED.name());
        dbClient.persistObject(mirrorObj);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error("Failed to resume single volume mirror: {}", mirror, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("fractureSingleVolumeMirror completed");
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 82 with BlockMirror

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

the class ControllerUtils method getGroupNameFromReplicas.

/**
 * Gets the replication group name from replicas of all volumes in CG.
 */
public static String getGroupNameFromReplicas(List<URI> replicas, BlockConsistencyGroup consistencyGroup, DbClient dbClient) {
    URI replicaURI = replicas.iterator().next();
    // get volumes part of this CG
    List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(consistencyGroup.getId(), dbClient);
    // check if replica of any of these volumes have replicationGroupInstance set
    for (Volume volume : volumes) {
        if (URIUtil.isType(replicaURI, BlockSnapshot.class)) {
            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() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
                    return snapshot.getReplicationGroupInstance();
                }
            }
        } else if (URIUtil.isType(replicaURI, Volume.class)) {
            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() && NullColumnValueGetter.isNotNullValue(clone.getReplicationGroupInstance())) {
                    return clone.getReplicationGroupInstance();
                }
            }
        } else if (URIUtil.isType(replicaURI, BlockMirror.class)) {
            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() && NullColumnValueGetter.isNotNullValue(mirror.getReplicationGroupInstance())) {
                    return mirror.getReplicationGroupInstance();
                }
            }
        }
    }
    return null;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Iterator(java.util.Iterator) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 83 with BlockMirror

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

the class BlockMirrorDetachCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        _log.info("START BlockMirrorDetachCompleter " + status);
        super.complete(dbClient, status, coded);
        List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
        for (BlockMirror mirror : mirrorList) {
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
            if (status == Status.ready) {
                _log.info("Removing sync details for mirror " + mirror.getId());
                mirror.setSynchronizedInstance(NullColumnValueGetter.getNullStr());
                mirror.setSyncState(NullColumnValueGetter.getNullStr());
                dbClient.persistObject(mirror);
                _log.info("Removing mirror {} from source volume {}", mirror.getId().toString(), volume.getId().toString());
                if (volume.getMirrors() != null) {
                    volume.getMirrors().remove(mirror.getId().toString());
                    dbClient.persistObject(volume);
                }
            }
            switch(status) {
                case error:
                    dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                    break;
                default:
                    dbClient.ready(Volume.class, volume.getId(), getOpId());
            }
            recordBlockMirrorOperation(dbClient, OperationTypeEnum.DETACH_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
        }
    } catch (Exception e) {
        _log.error("Failed updating status. BlockMirrorDetach {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 84 with BlockMirror

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

the class BlockMirrorFractureCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        super.complete(dbClient, status, coded);
        List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
        for (BlockMirror mirror : mirrorList) {
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
            switch(status) {
                case error:
                    dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                    break;
                default:
                    mirror.setSyncState(SynchronizationState.FRACTURED.toString());
                    dbClient.persistObject(mirror);
                    dbClient.ready(Volume.class, volume.getId(), getOpId());
            }
            recordBlockMirrorOperation(dbClient, OperationTypeEnum.FRACTURE_VOLUME_MIRROR, Status.ready, eventMessage(status, volume, mirror), mirror, volume);
        }
    } catch (Exception e) {
        _log.error("Failed updating status. BlockMirrorCreate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 85 with BlockMirror

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

the class SmisCommandHelper method getBlockObjectAlternateName.

/**
 * This method will take a URI and return alternateName for the BlockObject object to which the
 * URI applies.
 *
 * @param uri
 *            - URI
 * @return Returns a nativeId String value
 * @throws DeviceControllerException.exceptions.notAVolumeOrBlocksnapshotUri
 *             if URI is not a Volume/BlockSnapshot URI
 */
public String getBlockObjectAlternateName(URI uri) throws Exception {
    String nativeId;
    if (URIUtil.isType(uri, Volume.class)) {
        Volume volume = _dbClient.queryObject(Volume.class, uri);
        nativeId = volume.getAlternateName();
    } else if (URIUtil.isType(uri, BlockSnapshot.class)) {
        BlockSnapshot blockSnapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
        nativeId = blockSnapshot.getAlternateName();
    } else if (URIUtil.isType(uri, BlockMirror.class)) {
        BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, uri);
        nativeId = blockMirror.getAlternateName();
    } else {
        throw DeviceControllerException.exceptions.notAVolumeOrBlocksnapshotUri(uri);
    }
    return nativeId;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot)

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