Search in sources :

Example 36 with BlockMirror

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

the class StorageVolumeViewProcessor method processVolumes.

private void processVolumes(CloseableIterator<CIMInstance> volumeInstances, Map<String, Object> keyMap) throws IOException {
    List<CIMObjectPath> metaVolumes = new ArrayList<>();
    while (volumeInstances.hasNext()) {
        CIMInstance volumeViewInstance = volumeInstances.next();
        String nativeGuid = getVolumeViewNativeGuid(volumeViewInstance.getObjectPath(), keyMap);
        if (isSnapShot(volumeViewInstance)) {
            BlockSnapshot snapShot = checkSnapShotExistsInDB(nativeGuid, _dbClient);
            if (null == snapShot || snapShot.getInactive()) {
                _logger.debug("Skipping Snapshot, as its not being managed in Bourne");
                continue;
            }
            updateBlockSnapShot(volumeViewInstance, snapShot, keyMap);
            if (_updateSnapShots.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
                _updateSnapShots.clear();
            }
        } else if (isMirror(volumeViewInstance)) {
            BlockMirror mirror = checkBlockMirrorExistsInDB(nativeGuid, _dbClient);
            if (null == mirror || mirror.getInactive()) {
                _logger.debug("Skipping Mirror, as its not being managed in Bourne");
                continue;
            }
            updateBlockMirror(volumeViewInstance, mirror, keyMap);
            if (_updateMirrors.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
                _updateMirrors.clear();
            }
        } else {
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, _dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                continue;
            }
            _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
            updateStorageVolume(volumeViewInstance, storageVolume, keyMap);
            // This is applicable for meta volumes discovered as unmanaged volumes and ingested prior to vipr controller 2.2 .
            if (storageVolume.getIsComposite() && (storageVolume.getCompositionType() == null || storageVolume.getCompositionType().isEmpty())) {
                // meta volume is missing meta related data. Need to discover this data and set in the volume.
                metaVolumes.add(volumeViewInstance.getObjectPath());
                _logger.info("Found meta volume in vipr with missing data: {}, name: {}", volumeViewInstance.getObjectPath(), storageVolume.getLabel());
            }
        }
        if (_updateVolumes.size() > BATCH_SIZE) {
            _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
            _updateVolumes.clear();
        }
    }
    // Add meta volumes to the keyMap
    try {
        if (metaVolumes != null && !metaVolumes.isEmpty()) {
            _metaVolumeViewPaths.addAll(metaVolumes);
            _logger.info("Added  {} meta volumes.", metaVolumes.size());
        }
    } catch (Exception ex) {
        _logger.error("Processing meta volumes.", ex);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 37 with BlockMirror

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

the class StorageVolumeViewProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
        _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
        if (_metaVolumeViewPaths == null) {
            _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
        }
        // create empty place holder list for meta volume paths (cannot define this in xml)
        List<CIMObjectPath> metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (metaVolumePaths == null) {
            keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
        }
        CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
        volumeInstances = volumeInstanceChunks.getResponses();
        processVolumes(volumeInstances, keyMap);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), keyMap);
        }
        // if list empty, this method returns back immediately.
        // partition size might not be used in this context, as batch size < partition size.
        // TODO metering might need some extra work to push volumes in batches, hence not changing this method
        // signature
        _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
        _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
        _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
    } catch (Exception e) {
        _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
        _updateVolumes = null;
        _updateSnapShots = null;
        _updateMirrors = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 38 with BlockMirror

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

the class AbstractMirrorOperations method detachSingleVolumeMirror.

@Override
public void detachSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("detachSingleVolumeMirror operation START");
    try {
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        CIMArgument[] inArgs = _helper.getDetachSynchronizationInputArguments(storage, mirrorObj);
        CIMArgument[] outArgs = new CIMArgument[5];
        // Invoke method to detach the local mirror
        UnsignedInteger32 result = (UnsignedInteger32) _helper.callModifyReplica(storage, inArgs, outArgs);
        if (JOB_COMPLETED_NO_ERROR.equals(result)) {
            taskCompleter.ready(_dbClient);
        } else {
            String msg = String.format("SMI-S call returned unsuccessfully: %s", result);
            taskCompleter.error(_dbClient, DeviceControllerException.errors.smis.jobFailed(msg));
        }
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        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) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 39 with BlockMirror

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

the class AbstractMirrorOperations method resumeSingleVolumeMirror.

@Override
public void resumeSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("resumeSingleVolumeMirror operation START");
    CloseableIterator<CIMObjectPath> storageSyncRefs = null;
    try {
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        CIMObjectPath mirrorPath = _cimPath.getBlockObjectPath(storage, mirrorObj);
        // Get reference to the CIM_StorageSynchronized instance
        storageSyncRefs = _helper.getReference(storage, mirrorPath, SmisConstants.CIM_STORAGE_SYNCHRONIZED, null);
        if (!storageSyncRefs.hasNext()) {
            _log.error("No synchronization instance found for {}", mirror);
            taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resumeVolumeMirrorFailed(mirror));
            return;
        }
        boolean isVmax3 = storage.checkIfVmax3();
        while (storageSyncRefs.hasNext()) {
            CIMObjectPath storageSync = storageSyncRefs.next();
            _log.debug(storageSync.toString());
            /**
             * JIRA CTRL-11855
             * User created mirror and did pause operation using SMI 4.6.2.
             * Then He upgraded to SMI 8.0.3. While doing mirror resume getting exception from SMI because of the
             * existing mirrorObj.getSynchronizedInstance() contains SystemName=\"SYMMETRIX+000195701573\""
             * This is wrong with 8.0.3 as SystemName=\"SYMMETRIX-+-000195701573\"".
             * To resolve this issue setting new value collected from current smis provider here.
             */
            mirrorObj.setSynchronizedInstance(storageSync.toString());
            _dbClient.persistObject(mirrorObj);
            CIMArgument[] inArgs = isVmax3 ? _helper.getResumeSynchronizationInputArgumentsWithCopyState(storageSync) : _helper.getResumeSynchronizationInputArguments(storageSync);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storage, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockResumeMirrorJob(job, storage.getId(), taskCompleter)));
            } else {
                CIMInstance syncObject = _helper.getInstance(storage, storageSync, false, false, new String[] { SmisConstants.CP_SYNC_STATE });
                mirrorObj.setSyncState(CIMPropertyFactory.getPropertyValue(syncObject, SmisConstants.CP_SYNC_STATE));
                _dbClient.persistObject(mirrorObj);
                taskCompleter.ready(_dbClient);
            }
        }
    } catch (Exception e) {
        _log.error("Failed to resume single volume mirror: {}", mirror);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    } finally {
        if (storageSyncRefs != null) {
            storageSyncRefs.close();
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockResumeMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResumeMirrorJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 40 with BlockMirror

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

the class AbstractMirrorOperations method deleteSingleVolumeMirror.

@Override
public void deleteSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("deleteSingleVolumeMirror operation START");
    try {
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        if (storage.checkIfVmax3()) {
            _helper.removeVolumeFromParkingSLOStorageGroup(storage, new String[] { mirrorObj.getNativeId() }, false);
            _log.info("Done invoking remove volume {} from parking SLO storage group", mirrorObj.getNativeId());
        }
        CIMObjectPath mirrorPath = _cimPath.getBlockObjectPath(storage, mirrorObj);
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storage);
        CIMArgument[] inArgs = _helper.getDeleteMirrorInputArguments(storage, mirrorPath);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, configSvcPath, SmisConstants.RETURN_TO_STORAGE_POOL, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockDeleteMirrorJob(job, storage.getId(), taskCompleter)));
        }
    } catch (Exception e) {
        _log.info("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) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) SmisBlockDeleteMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockDeleteMirrorJob) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) 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