Search in sources :

Example 61 with BlockMirror

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

the class SmisCommandHelper method disableVMAX3Compression.

/**
 * This method is will check if the Storage Pool associated with the Volume supports compression.
 * If it does support compression, it will check if the associated virtual Pool has compression enabled.
 * It will recommend the user to disable compression if the virtual pool has compression disabled and
 * the storage pool enables compression by default.
 *
 * @param blockObjectURI BlockObjectURI
 * @param storage - StorageSystem object
 * @return boolean to report if compression needs to be disabled.
 */
public boolean disableVMAX3Compression(URI blockObjectURI, StorageSystem storageSystem) {
    VirtualPool virtualPool = null;
    StoragePool storagePool = null;
    Volume volume = null;
    if (URIUtil.isType(blockObjectURI, Volume.class)) {
        volume = _dbClient.queryObject(Volume.class, blockObjectURI);
        // Using the same logic that is in the above getVMAX3FastSettingForVolume method.
        // If the there is a BlockSnapshot with the same native GUID as the volume, then
        // this is a backend volume representing the snapshot for the purpose of importing
        // the snapshot into VPLEX as a VPLEX volume. Therefore, treat it like a block snapshot
        // and use the parent volume.
        List<BlockSnapshot> snapshots = CustomQueryUtility.getActiveBlockSnapshotByNativeGuid(_dbClient, volume.getNativeGuid());
        if (!snapshots.isEmpty()) {
            volume = _dbClient.queryObject(Volume.class, snapshots.get(0).getParent());
        }
    } else if (URIUtil.isType(blockObjectURI, BlockSnapshot.class)) {
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, blockObjectURI);
        volume = _dbClient.queryObject(Volume.class, snapshot.getParent());
    } else if (URIUtil.isType(blockObjectURI, BlockMirror.class)) {
        BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, blockObjectURI);
        if (NullColumnValueGetter.isNullURI(mirror.getVirtualPool()) || NullColumnValueGetter.isNullURI(mirror.getPool())) {
            _log.info("The given BlockMirror {} does not have an associated Virtual pool or Storage Pool ", blockObjectURI);
            // This should never happen but we need this additional check.
            return false;
        }
        virtualPool = _dbClient.queryObject(VirtualPool.class, mirror.getVirtualPool());
        storagePool = _dbClient.queryObject(StoragePool.class, mirror.getPool());
    }
    if (volume != null) {
        if (NullColumnValueGetter.isNullURI(volume.getVirtualPool()) || NullColumnValueGetter.isNullURI(volume.getPool())) {
            _log.info("The given Volume {} does not have an associated Virtual pool or Storage Pool ", blockObjectURI);
            // This should never happen but we need this additional check.
            return false;
        }
        virtualPool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        storagePool = _dbClient.queryObject(StoragePool.class, volume.getPool());
    }
    return (checkIfProviderSupportsCompressionOperations(storageSystem) && !virtualPool.getCompressionEnabled() && storagePool.getCompressionEnabled());
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 62 with BlockMirror

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

the class SmisCommandHelper method getNativeGuidToVolumeUriMap.

/**
 * Generate NativeGuid-->Volume uri mapping using volume uris list.
 *
 * @param volumeUris
 * @param storage
 * @return
 * @throws IOException
 */
private Map<String, URI> getNativeGuidToVolumeUriMap(List<URI> volumeUris, StorageSystem storage) throws IOException {
    Map<String, URI> volumePaths = new HashMap<String, URI>();
    for (URI volumeUri : volumeUris) {
        String nativeGuid = null;
        if (URIUtil.isType(volumeUri, Volume.class)) {
            Volume volume = _dbClient.queryObject(Volume.class, volumeUri);
            nativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, volume);
        } else if (URIUtil.isType(volumeUri, BlockSnapshot.class)) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, volumeUri);
            nativeGuid = NativeGUIDGenerator.generateNativeGuid(storage, snapshot);
        } else if (URIUtil.isType(volumeUri, BlockMirror.class)) {
            BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, volumeUri);
            nativeGuid = NativeGUIDGenerator.generateNativeGuid(storage, mirror);
        }
        volumePaths.put(nativeGuid, volumeUri);
    }
    return volumePaths;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI)

Example 63 with BlockMirror

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

the class VmaxMirrorOperations method createGroupMirrors.

@Override
public void createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createGroupMirrors operation START");
    List<BlockMirror> mirrors = null;
    try {
        if (!storage.getUsingSmis80()) {
            throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
        }
        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);
        String replicaLabel = ControllerUtils.generateLabel(sourceVolume.getLabel(), firstMirror.getLabel());
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        // Create CG mirrors
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, replicaLabel, null, createInactive, taskCompleter, SYNC_TYPE.MIRROR, _dbClient, _helper, _cimPath);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGMirrorJob(job, storage.getId(), 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
        if (mirrors != null && !mirrors.isEmpty()) {
            for (BlockMirror mirrorObj : mirrors) {
                mirrorObj.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) Volume(com.emc.storageos.db.client.model.Volume) SmisBlockCreateCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGMirrorJob) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 64 with BlockMirror

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

the class VmaxMirrorOperations method fractureGroupMirrors.

@Override
public void fractureGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean sync, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("fractureGroupMirrors 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);
        }
        // If there is any mirror in split state, resume the group to make it consistent.
        if (_helper.groupHasReplicasInSplitState(storage, mirrorList, BlockMirror.class)) {
            resumeGroupMirrors(storage, mirrorList);
        }
        // Fracture the mirror now.
        CIMArgument[] fractureCGMirrorInput = _helper.getFractureMirrorInputArgumentsWithCopyState(groupSynchronized, sync);
        _helper.callModifyReplica(storage, fractureCGMirrorInput);
        List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        for (BlockMirror mirror : mirrors) {
            mirror.setSyncState(SynchronizationState.FRACTURED.name());
        }
        _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);
    }
}
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) CIMArgument(javax.cim.CIMArgument)

Example 65 with BlockMirror

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

the class VmaxMirrorOperations method removeMirrorFromDeviceMaskingGroup.

@Override
public void removeMirrorFromDeviceMaskingGroup(StorageSystem system, List<URI> mirrorList, TaskCompleter completer) throws DeviceControllerException {
    _log.info("removeMirrorFromGroup operation START");
    try {
        BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
        CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(system, mirror.getReplicationGroupInstance(), SmisConstants.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
        List<URI> replicasPartOfGroup = _helper.findVolumesInReplicationGroup(system, maskingGroupPath, mirrorList);
        if (replicasPartOfGroup.isEmpty()) {
            _log.info("Mirrors {} already removed from Device Masking Group {}", Joiner.on(", ").join(mirrorList), maskingGroupPath);
        } else {
            String[] members = _helper.getBlockObjectAlternateNames(replicasPartOfGroup);
            CIMObjectPath[] memberPaths = _cimPath.getVolumePaths(system, members);
            CIMArgument[] inArgs = _helper.getRemoveAndUnmapMaskingGroupMembersInputArguments(maskingGroupPath, memberPaths, system, false);
            CIMArgument[] outArgs = new CIMArgument[5];
            _log.info("Invoking remove mirrors {} from Device Masking Group equivalent to its Replication Group {}", Joiner.on(", ").join(members), mirror.getReplicationGroupInstance());
            _helper.invokeMethodSynchronously(system, _cimPath.getControllerConfigSvcPath(system), SmisConstants.REMOVE_MEMBERS, inArgs, outArgs, null);
        }
        completer.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Failed to remove mirrors from its Device Masking Group. Mirrors: {}", Joiner.on(", ").join(mirrorList), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(_dbClient, serviceError);
    }
    _log.info("removeMirrorFromGroup operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

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