Search in sources :

Example 56 with UnManagedVolume

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

the class TierPolicyProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath storageGroupPath = getObjectPathfromCIMArgument(_args);
        @SuppressWarnings("unchecked") Map<String, CIMObjectPath> volumeToStorageGroupMapping = (Map<String, CIMObjectPath>) keyMap.get(Constants.VOLUME_STORAGE_GROUP_MAPPING);
        CIMObjectPath volumePath = volumeToStorageGroupMapping.get(storageGroupPath.getKey(Constants.INSTANCEID).getValue().toString());
        String nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
        UnManagedVolume preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, _dbClient);
        if (null == preExistingVolume) {
            return;
        }
        // get VolumeInfo Object and inject Fast Policy Name.
        @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        while (it.hasNext()) {
            CIMObjectPath policyPath = it.next();
            injectIntoVolumeInformationContainer(preExistingVolume, Constants.POLICYRULENAME, policyPath);
            preExistingVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
        }
        _dbClient.persistObject(preExistingVolume);
    } catch (Exception e) {
        _logger.error("Processing Tier Policy in Pre Existing Volume  failed", e);
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) Map(java.util.Map) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 57 with UnManagedVolume

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

the class VNXFastVolumesProcessor method processVolumes.

private void processVolumes(Iterator<CIMObjectPath> it, CIMObjectPath tierPolicyPath, Map<String, Object> keyMap, Operation operation) {
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
    while (it.hasNext()) {
        CIMObjectPath volumePath = null;
        try {
            volumePath = it.next();
            if (tierPolicyPath.toString().contains(AutoTieringPolicy.VnxFastPolicy.DEFAULT_AUTOTIER.toString())) {
                _logger.debug("Adding Auto Tier Policy Rule ");
                addPath(keyMap, operation.getResult(), volumePath);
                continue;
            }
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume {} is already being managed by ViPR.", volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                String policyName = getCIMPropertyValue(tierPolicyPath, Constants.POLICYRULENAME);
                _logger.info("Adding {} Policy Rule to UnManaged Volume {}", policyName, unManagedVolumeNativeGuid);
                injectIntoVolumeInformationContainer(unManagedVolume, Constants.POLICYRULENAME, tierPolicyPath);
                unManagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
                // StorageVolumeInfoProcessor updated supported_vpool_list based on its pool's presence in vPool
                // Now, filter those vPools based on policy associated
                DiscoveryUtils.filterSupportedVpoolsBasedOnTieringPolicy(unManagedVolume, policyName, system, _dbClient);
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume {} ", volumePath, ex);
        }
    }
}
Also used : 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) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 58 with UnManagedVolume

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

the class VNXFastVolumesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMObjectPath> volumeInstances = null;
    try {
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
        @SuppressWarnings("unchecked") EnumerateResponse<CIMObjectPath> volumeInstanceChunks = (EnumerateResponse<CIMObjectPath>) resultObj;
        volumeInstances = volumeInstanceChunks.getResponses();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath tierPolicypath = getObjectPathfromCIMArgument(_args);
        processVolumes(volumeInstances, tierPolicypath, keyMap, operation);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancePaths(tierPolicypath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), tierPolicypath, keyMap, operation);
        }
        if (!_unManagedVolumesUpdate.isEmpty()) {
            _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
            _unManagedVolumesUpdate.clear();
        }
    } catch (Exception e) {
        _logger.error("Discovering Tier Policies for vnx volumes failed", e);
    } finally {
        volumeInstances.close();
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 59 with UnManagedVolume

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

the class VolumeAccessStateProcessor method processVolumes.

private void processVolumes(Iterator<CIMInstance> it, Map<String, Object> keyMap, Operation operation) {
    while (it.hasNext()) {
        try {
            CIMInstance volumeInstance = it.next();
            CIMObjectPath volumePath = volumeInstance.getObjectPath();
            // TODO add logic to get Access
            String access = null;
            Object value = volumeInstance.getPropertyValue(SupportedVolumeInformation.ACCESS.toString());
            if (value != null) {
                access = value.toString();
            }
            StringSet statusDesc = new StringSet();
            String[] descriptions = null;
            value = volumeInstance.getPropertyValue(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString());
            if (value != null) {
                descriptions = (String[]) value;
                for (String desc : descriptions) {
                    statusDesc.add(desc);
                }
            }
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume is already being managed by ViPR :" + volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                _logger.debug("Adding Access {}", unManagedVolumeNativeGuid);
                StringSet accessSet = new StringSet();
                if (access != null) {
                    accessSet.add(access);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.ACCESS.toString(), accessSet);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString()).replace(accessSet);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString(), statusDesc);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString()).replace(statusDesc);
                }
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume", ex);
        }
    }
}
Also used : 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) CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 60 with UnManagedVolume

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

the class VolumeDiscoveryPostProcessor method setSupportedVPoolsForReplicas.

private void setSupportedVPoolsForReplicas(Map<String, LocalReplicaObject> volumeToReplicaMap, DbClient dbClient) {
    _logger.info("Post processing UnManagedVolumes setSupportedVPoolsForReplicas");
    List<UnManagedVolume> modifiedUnManagedVolumes = new ArrayList<UnManagedVolume>();
    // for each source, set SUPPORTED_VPOOL_LIST for its targets
    for (Entry<String, LocalReplicaObject> entry : volumeToReplicaMap.entrySet()) {
        String srcNativeGuid = entry.getKey();
        LocalReplicaObject srcObj = entry.getValue();
        if (srcObj.hasReplica() && !srcObj.isReplica()) {
            // process its dependents
            try {
                StringSet vPools = null;
                // check if unmanaged volume is created
                UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(srcNativeGuid, dbClient);
                if (unManagedVolume != null) {
                    vPools = unManagedVolume.getSupportedVpoolUris();
                } else {
                    // check if it has already been ingested
                    String volumeNativeGuid = srcNativeGuid.replace(NativeGUIDGenerator.UN_MANAGED_VOLUME, NativeGUIDGenerator.VOLUME);
                    Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, dbClient);
                    if (volume != null) {
                        _logger.debug("Volume {} is already being managed by ViPR", volumeNativeGuid);
                        vPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, volume.getPool(), volume.getThinlyProvisioned().toString(), unManagedVolume);
                    }
                }
                if (vPools != null && !vPools.isEmpty()) {
                    setVPoolsForDependents(vPools, srcObj, volumeToReplicaMap, modifiedUnManagedVolumes, dbClient);
                } else {
                    _logger.info("Cannot find supported VPools for {}", srcNativeGuid);
                }
            } catch (Exception e) {
                _logger.warn("Exception on setVPoolsForReplicas {}", e.getMessage());
            }
        }
        // if modifiedUnManagedVolumes size reaches BATCH_SIZE, persist to db
        if (modifiedUnManagedVolumes.size() >= BATCH_SIZE) {
            _partitionManager.updateAndReIndexInBatches(modifiedUnManagedVolumes, BATCH_SIZE, dbClient, "UnManagedVolumes");
            modifiedUnManagedVolumes.clear();
        }
    }
    if (!modifiedUnManagedVolumes.isEmpty()) {
        _partitionManager.updateAndReIndexInBatches(modifiedUnManagedVolumes, BATCH_SIZE, dbClient, "UnManagedVolumes");
    }
}
Also used : 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) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10