Search in sources :

Example 96 with BlockMirror

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

the class AbstractMirrorOperations method deleteGroupMirrors.

@Override
public void deleteGroupMirrors(StorageSystem storage, List<URI> mirrorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("deleteGroupMirrors operation START");
    if (!((storage.getUsingSmis80() && storage.deviceIsType(Type.vmax)) || storage.deviceIsType(Type.vnxblock))) {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
    try {
        String[] deviceIds = null;
        BlockMirror firstMirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
        String repGroupName = firstMirror.getReplicationGroupInstance();
        if (NullColumnValueGetter.isNotNullValue(repGroupName)) {
            CIMObjectPath repGroupPath = _cimPath.getReplicationGroupPath(storage, repGroupName);
            Set<String> deviceIdsSet = _helper.getVolumeDeviceIdsFromStorageGroup(storage, repGroupPath);
            deviceIds = deviceIdsSet.toArray(new String[deviceIdsSet.size()]);
            // Delete replication group
            ReplicationUtils.deleteReplicationGroup(storage, repGroupName, _dbClient, _helper, _cimPath);
            // Set mirrors replication group to null
            List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
            for (BlockMirror mirror : mirrors) {
                mirror.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                mirror.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
            }
            _dbClient.persistObject(mirrors);
        } else {
            deviceIds = _helper.getBlockObjectNativeIds(mirrorList);
        }
        if (storage.checkIfVmax3()) {
            _helper.removeVolumeFromParkingSLOStorageGroup(storage, deviceIds, false);
            _log.info("Done invoking remove volumes from parking SLO storage group");
        }
        CIMObjectPath[] mirrorPaths = _cimPath.getVolumePaths(storage, deviceIds);
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storage);
        CIMArgument[] inArgs = null;
        if (storage.deviceIsType(Type.vnxblock)) {
            inArgs = _helper.getReturnElementsToStoragePoolArguments(mirrorPaths);
        } else {
            inArgs = _helper.getReturnElementsToStoragePoolArguments(mirrorPaths, SmisConstants.CONTINUE_ON_NONEXISTENT_ELEMENT);
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, configSvcPath, SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockDeleteCGMirrorJob(job, storage.getId(), taskCompleter)));
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
}
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) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument) SmisBlockDeleteCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockDeleteCGMirrorJob)

Example 97 with BlockMirror

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

the class AbstractReplicaOperations method detachListReplica.

@Override
public void detachListReplica(StorageSystem storage, List<URI> replicaList, TaskCompleter taskCompleter) {
    _log.info("detachListReplica operation START");
    try {
        List<? extends BlockObject> replicas = BlockObject.fetchAll(_dbClient, replicaList);
        modifyListReplica(storage, replicaList, replicas, SmisConstants.DETACH_VALUE, SmisConstants.NON_COPY_STATE);
        for (BlockObject replica : replicas) {
            if (replica instanceof BlockMirror) {
                BlockMirror mirror = (BlockMirror) replica;
                mirror.setReplicaState(ReplicationState.DETACHED.name());
                mirror.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                mirror.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
                mirror.setSynchronizedInstance(NullColumnValueGetter.getNullStr());
                mirror.setSyncState(NullColumnValueGetter.getNullStr());
                Volume volume = _dbClient.queryObject(Volume.class, mirror.getSource());
                if (volume.getMirrors() != null) {
                    volume.getMirrors().remove(mirror.getId().toString());
                    _dbClient.updateObject(volume);
                }
            } else if (replica instanceof Volume) {
                Volume clone = (Volume) replica;
                ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(clone, _dbClient);
                clone.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
                clone.setReplicaState(ReplicationState.DETACHED.name());
            }
        }
        _dbClient.updateObject(replicas);
        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("detachListReplica 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) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 98 with BlockMirror

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

the class SmisCommandHelper method getVMAX3FastPolicyNameForVolume.

private String getVMAX3FastPolicyNameForVolume(URI blockObjectURI, String autoTierPolicyName, Boolean compression) {
    VirtualPool virtualPool = null;
    StringBuffer policyName = new StringBuffer();
    Volume volume = null;
    boolean compressionEnabled = false;
    if (URIUtil.isType(blockObjectURI, Volume.class)) {
        volume = _dbClient.queryObject(Volume.class, blockObjectURI);
        // 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);
        virtualPool = _dbClient.queryObject(VirtualPool.class, mirror.getVirtualPool());
        compressionEnabled = virtualPool.getCompressionEnabled();
        if (compression != null) {
            compressionEnabled = compression;
        }
        policyName = getPolicyByBlockObject(mirror.getPool(), autoTierPolicyName, mirror.getAutoTieringPolicyUri(), compressionEnabled);
    }
    if (volume != null) {
        virtualPool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        compressionEnabled = virtualPool.getCompressionEnabled();
        if (compression != null) {
            compressionEnabled = compression;
        }
        policyName = getPolicyByBlockObject(volume.getPool(), autoTierPolicyName, volume.getAutoTieringPolicyUri(), compressionEnabled);
    }
    return policyName.toString();
}
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) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 99 with BlockMirror

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

the class VolumeIngestionUtil method clearMirrorsFlags.

/**
 * Clear the flags of the mirrors of the RP volume
 *
 * @param requestContext current unManagedVolume Ingestion context.
 * @param volumes the Volume Objects to clear flags on
 * @param updatedObjects a Set of DataObjects to be updated in the database at the end of ingestion
 * @param dbClient - dbClient reference.
 */
public static void clearMirrorsFlags(IngestionRequestContext requestContext, Volume volume, Set<DataObject> updatedObjects, DbClient dbClient) {
    if (volume.getMirrors() != null) {
        for (String volumeId : volume.getMirrors()) {
            BlockObject bo = requestContext.findDataObjectByType(BlockMirror.class, URI.create(volumeId), true);
            if (null != bo && bo instanceof BlockMirror) {
                _logger.info("Clearing internal volume flag of mirror {} of RP volume {}", bo.getLabel(), volume.getLabel());
                bo.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
                updatedObjects.add(bo);
            }
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 100 with BlockMirror

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

the class BlockIngestOrchestrator method setupParentReplicaRelationships.

private void setupParentReplicaRelationships(UnManagedVolume currentUnmanagedVolume, Map<BlockObject, List<BlockObject>> parentReplicaMap, IngestionRequestContext requestContext, List<UnManagedVolume> processedUnManagedVolumes) {
    Set<DataObject> updateObjects = requestContext.getDataObjectsToBeUpdatedMap().get(currentUnmanagedVolume.getNativeGuid());
    if (updateObjects == null) {
        updateObjects = new HashSet<DataObject>();
        requestContext.getDataObjectsToBeUpdatedMap().put(currentUnmanagedVolume.getNativeGuid(), updateObjects);
    }
    String currentBlockObjectNativeGuid = currentUnmanagedVolume.getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
    UnManagedProtectionSet umpset = null;
    boolean allRPCGVolumesIngested = true;
    boolean isParentRPVolume = false;
    for (BlockObject parent : parentReplicaMap.keySet()) {
        boolean parentIsCurrentUnManagedVolume = parent.getNativeGuid().equals(currentBlockObjectNativeGuid);
        // don't clear flags if the current block object is for the currently ingesting UnManagedvolume
        if (!parentIsCurrentUnManagedVolume) {
            VolumeIngestionUtil.clearInternalFlags(requestContext, parent, updateObjects, _dbClient);
        }
        // added to the collection of objects to be updated rather than created
        if (null == requestContext.getRootIngestionRequestContext().findCreatedBlockObject(parent.getNativeGuid())) {
            updateObjects.add(parent);
        }
        UnManagedVolume parentRPUmVolume = VolumeIngestionUtil.getRPUnmanagedVolume(parent, _dbClient);
        isParentRPVolume = parentRPUmVolume != null;
        // if its RP volume, then check whether the RP CG is fully ingested.
        if (isParentRPVolume && !parentIsCurrentUnManagedVolume) {
            List<UnManagedVolume> ingestedUnManagedVolumes = requestContext.findAllUnManagedVolumesToBeDeleted();
            ingestedUnManagedVolumes.add(parentRPUmVolume);
            umpset = VolumeIngestionUtil.getUnManagedProtectionSetForUnManagedVolume(requestContext, parentRPUmVolume, _dbClient);
            // has already been ingested. In this case, try to get it from the managed volume
            if (umpset == null) {
                BlockObject parentRPVolume = VolumeIngestionUtil.getRPVolume(requestContext, parent, _dbClient);
                umpset = VolumeIngestionUtil.getUnManagedProtectionSetForManagedVolume(requestContext, parentRPVolume, _dbClient);
            }
            allRPCGVolumesIngested = VolumeIngestionUtil.validateAllVolumesInCGIngested(ingestedUnManagedVolumes, umpset, requestContext, _dbClient);
            // If not fully ingested, mark the volume as internal. This will be marked visible when the RP CG is ingested
            if (!allRPCGVolumesIngested) {
                parent.addInternalFlags(INTERNAL_VOLUME_FLAGS);
            }
        }
        for (BlockObject replica : parentReplicaMap.get(parent)) {
            if (replica instanceof BlockMirror) {
                VolumeIngestionUtil.setupMirrorParentRelations(replica, parent, _dbClient);
            } else if (replica instanceof Volume) {
                if (isSRDFTargetVolume(replica, processedUnManagedVolumes)) {
                    VolumeIngestionUtil.setupSRDFParentRelations(replica, parent, _dbClient);
                } else if (VolumeIngestionUtil.isVplexVolume(parent, _dbClient)) {
                    if (parent instanceof Volume) {
                        StringSet associatedVolumes = ((Volume) parent).getAssociatedVolumes();
                        if (associatedVolumes != null && associatedVolumes.contains(replica.getId().toString())) {
                            _logger.info("associated volume {} of {} has already been ingested", replica.forDisplay(), parent.forDisplay());
                        } else if (VolumeIngestionUtil.isVplexBackendVolume(replica, _dbClient)) {
                            VolumeIngestionUtil.setupVplexParentRelations(replica, parent, _dbClient);
                        }
                    }
                } else {
                    VolumeIngestionUtil.setupCloneParentRelations(replica, parent, _dbClient);
                }
            } else if (replica instanceof BlockSnapshot) {
                VolumeIngestionUtil.setupSnapParentRelations(replica, parent, _dbClient);
            }
            // don't clear flags if the current block object is for the currently ingesting UnManagedvolume
            if (!replica.getNativeGuid().equals(currentBlockObjectNativeGuid)) {
                VolumeIngestionUtil.clearInternalFlags(requestContext, replica, updateObjects, _dbClient);
            }
            // Snaps/mirror/clones of RP volumes should be made visible only after the RP CG has been fully ingested.
            if (isParentRPVolume && !allRPCGVolumesIngested) {
                replica.addInternalFlags(INTERNAL_VOLUME_FLAGS);
            }
            if (null == requestContext.findCreatedBlockObject(replica.getNativeGuid())) {
                updateObjects.add(replica);
            }
        }
    }
    // If RP volume and fully ingested, set up the RP CG
    if (isParentRPVolume && allRPCGVolumesIngested && umpset != null) {
        VolumeIngestionUtil.validateRPVolumesAlignWithIngestVpool(requestContext, umpset, _dbClient);
        VolumeIngestionUtil.setupRPCG(requestContext, umpset, currentUnmanagedVolume, updateObjects, _dbClient);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

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