Search in sources :

Example 46 with BlockMirror

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

the class VmaxMirrorOperations method establishVolumeNativeContinuousCopyGroupRelation.

@Override
public void establishVolumeNativeContinuousCopyGroupRelation(StorageSystem storage, URI sourceVolume, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("establishVolumeNativeContinuousCopyGroupRelation operation START");
    try {
        /**
         * get groupPath for source volume
         * get groupPath for mirror
         * get mirrors belonging to the same Replication Group
         * get Element synchronizations between volumes and mirrors
         * call CreateGroupReplicaFromElementSynchronizations
         */
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
        CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
        CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
        CIMObjectPath mirrorGroupPath = _cimPath.getReplicationGroupPath(storage, mirrorObj.getReplicationGroupInstance());
        CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, mirrorGroupPath);
        CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
        if (syncInstance == null) {
            // List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(sourceVolume.getConsistencyGroup(), _dbClient);
            // get all mirrors belonging to a Replication Group. There may be multiple mirrors available for a Volume
            List<BlockMirror> mirrors = ControllerUtils.getMirrorsPartOfReplicationGroup(mirrorObj.getReplicationGroupInstance(), _dbClient);
            List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
            for (BlockMirror mirrorObject : mirrors) {
                Volume volume = _dbClient.queryObject(Volume.class, mirrorObject.getSource());
                elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, mirrorObject));
            }
            _log.info("Creating Group synchronization between volume group and mirror group");
            CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, mirrorGroupPath, elementSynchronizations);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
        // No Job returned
        } else {
            _log.info("Link already established..");
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Failed to establish group relation between volume group and mirror group. Volume: {}, Mirror: {}", sourceVolume, mirror);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 47 with BlockMirror

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

the class VmaxMirrorOperations method resumeGroupMirrors.

@Override
public void resumeGroupMirrors(StorageSystem storage, List<URI> mirrorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("resumeGroupMirrors operation START");
    if (!storage.getUsingSmis80()) {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, mirrorList);
        CIMObjectPath groupSynchronized = ReplicationUtils.getMirrorGroupSynchronizedPath(storage, mirrorList.get(0), _dbClient, _helper, _cimPath);
        if (null == _helper.checkExists(storage, groupSynchronized, false, false)) {
            _log.error("Unable to find group synchronized {}", groupSynchronized.toString());
            BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(mirror.getReplicationGroupInstance());
            taskCompleter.error(_dbClient, error);
            return;
        }
        resumeGroupMirrors(storage, mirrorList);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call", e);
        ServiceError error = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 48 with BlockMirror

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

the class VnxMirrorOperations method detachGroupMirrors.

/*
     * (non-Javadoc)
     *
     * @see com.emc.storageos.volumecontroller.impl.smis.AbstractMirrorOperations#detachGroupMirrors(com.emc.storageos.db.client.model.
     * StorageSystem, java.util.List, java.lang.Boolean, com.emc.storageos.volumecontroller.TaskCompleter)
     * deleteGroup is not used for VNX
     */
@Override
public void detachGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean deleteGroup, TaskCompleter taskCompleter) {
    _log.info("START detachGroupMirrors operation");
    try {
        modifyGroupMirrors(storage, mirrorList, SmisConstants.DETACH_VALUE, SmisConstants.NON_COPY_STATE);
        List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        for (BlockMirror mirror : mirrors) {
            mirror.setReplicaState(ReplicationState.DETACHED.name());
            mirror.setConsistencyGroup(NullColumnValueGetter.getNullURI());
            mirror.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
            mirror.setSyncState(NullColumnValueGetter.getNullStr());
        }
        _dbClient.persistObject(mirrors);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call", e);
        ServiceError error = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, error);
    }
    _log.info("detachGroupMirrors operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 49 with BlockMirror

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

the class VnxMirrorOperations method createGroupMirrors.

/**
 * Should implement create of a mirror from a source volume that is part of a
 * consistency group.
 *
 * Implementation note: In this method we will kick of the asynchronous creation
 * of the target devices required for the CG clones. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group clone operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param mirrorList [required] - mirror URI list
 * @param createInactive whether the mirror needs to to be created with sync_active=true/false
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createGroupMirrors operation START");
    List<BlockMirror> mirrors = null;
    List<String> targetDeviceIds = null;
    try {
        mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        BlockMirror firstMirror = mirrors.get(0);
        Volume sourceVolume = _dbClient.queryObject(Volume.class, firstMirror.getSource());
        String sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVolume, _dbClient);
        if (!ControllerUtils.isNotInRealVNXRG(sourceVolume, _dbClient)) {
            // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
            ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        }
        List<String> sourceIds = new ArrayList<String>();
        targetDeviceIds = new ArrayList<String>();
        Map<String, String> tgtToSrcMap = new HashMap<String, String>();
        for (BlockMirror mirror : mirrors) {
            final URI poolId = mirror.getPool();
            final Volume source = _dbClient.queryObject(Volume.class, mirror.getSource());
            sourceIds.add(source.getNativeId());
            // Create target devices
            final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, mirror.getLabel(), createInactive, 1, poolId, mirror.getCapacity(), source.getThinlyProvisioned(), null, taskCompleter, _dbClient, _helper, _cimPath);
            targetDeviceIds.addAll(newDeviceIds);
            tgtToSrcMap.put(newDeviceIds.get(0), source.getNativeId());
        }
        CIMObjectPath[] targetDevicePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
        CIMObjectPath[] sourceDevicePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
        // Create list replica
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceDevicePaths, targetDevicePaths);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGMirrorJob(job, storage.getId(), tgtToSrcMap, taskCompleter)));
        for (BlockMirror mirror : mirrors) {
            mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
        }
        _dbClient.persistObject(mirrors);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        // Roll back changes
        ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
        if (mirrors != null && !mirrors.isEmpty()) {
            for (BlockMirror mirror : mirrors) {
                mirror.setInactive(true);
            }
        }
        _dbClient.persistObject(mirrors);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupMirrors", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("createGroupMirrors operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) SmisVnxCreateCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGMirrorJob) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 50 with BlockMirror

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

the class ExportMaskUtils 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 static String getBlockObjectAlternateName(URI uri, DbClient dbClient) 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