Search in sources :

Example 6 with StorageTier

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

the class TierPercentageProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    while (it.hasNext()) {
        try {
            CIMInstance symmAssociatedPolicyInstance = it.next();
            CIMObjectPath symmAssociatedPolicyPath = symmAssociatedPolicyInstance.getObjectPath();
            CIMObjectPath tierPath = (CIMObjectPath) symmAssociatedPolicyPath.getKey(DEPENDENT).getValue();
            String tierPercent = symmAssociatedPolicyInstance.getPropertyValue(MAX_PERCENT_ALLOCATED).toString();
            String tierID = tierPath.getKey(Constants.INSTANCEID).getValue().toString();
            String tierNativeGuid = getTierNativeGuidForVMax(tierID);
            StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, _dbClient);
            if (null != tierObject) {
                tierObject.setPercentage(tierPercent);
                _dbClient.persistObject(tierObject);
            }
        } catch (Exception e) {
            _logger.error("Vmax Tier Percentage Discovery failed", e);
        }
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) StorageTier(com.emc.storageos.db.client.model.StorageTier) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 7 with StorageTier

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

the class VMAXPolicyToTierProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        _updateTierList = new ArrayList<StorageTier>();
        _newTierList = new ArrayList<StorageTier>();
        // value will be set already always
        Object[] arguments = (Object[]) _args.get(0);
        Set<String> tierNativeGuidsfromProvider = new HashSet<String>();
        CIMObjectPath vmaxFastPolicyRule = (CIMObjectPath) arguments[0];
        String vmaxPolicyId = getFASTPolicyID(vmaxFastPolicyRule);
        AutoTieringPolicy vmaxFastPolicy = getAutoTieringPolicyByNameFromDB(vmaxPolicyId, _dbClient);
        // the relationship between Policy--->Pools
        while (it.hasNext()) {
            CIMInstance vmaxTierInstance = it.next();
            CIMObjectPath tierPath = vmaxTierInstance.getObjectPath();
            String tierID = tierPath.getKey(Constants.INSTANCEID).getValue().toString();
            // For 8.x -+- becomes +, internal DB format uses + only; for 4.6 remains as it is
            tierID = tierID.replaceAll(Constants.SMIS_80_STYLE, Constants.SMIS_PLUS_REGEX);
            if (keyMap.containsKey(tierID)) {
                List<CIMObjectPath> policyPaths = (List<CIMObjectPath>) keyMap.get(tierID);
                policyPaths.add(vmaxFastPolicyRule);
            } else {
                addPath(keyMap, Constants.STORAGETIERS, tierPath);
                List<CIMObjectPath> policyPaths = new ArrayList<CIMObjectPath>();
                policyPaths.add(vmaxFastPolicyRule);
                keyMap.put(tierID, policyPaths);
            }
            String tierNativeGuid = getTierNativeGuidForVMax(tierID);
            tierNativeGuidsfromProvider.add(tierNativeGuid);
            StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, _dbClient);
            String driveTechnologyIdentifier = vmaxTierInstance.getPropertyValue(Constants.TECHNOLOGY).toString();
            String driveType = StorageTier.SupportedTiers.getTier(driveTechnologyIdentifier);
            createStorageTier(vmaxTierInstance, tierObject, tierNativeGuid, vmaxFastPolicy.getId(), _newTierList, _updateTierList, driveType);
        }
        _dbClient.createObject(_newTierList);
        _dbClient.persistObject(_updateTierList);
        performStorageTierBookKeeping(tierNativeGuidsfromProvider, vmaxFastPolicy.getId());
    } catch (Exception e) {
        _logger.error("Policy to Tier Processing failed :", e);
    }
}
Also used : StorageTier(com.emc.storageos.db.client.model.StorageTier) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 8 with StorageTier

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

the class VMAXPolicyToTierProcessor method performStorageTierBookKeeping.

/**
 * remove Tiers which had been deleted from Array
 *
 * @param tierNativeGuidsfromProvider
 * @param id
 * @throws IOException
 */
private void performStorageTierBookKeeping(Set<String> tierNativeGuidsfromProvider, URI id) throws IOException {
    List<URI> tierUrisAssociatedWithPolicy = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierFASTPolicyConstraint(id.toString()));
    _logger.info("Tiers {} associated with Policy {}", Joiner.on("\t").join(tierUrisAssociatedWithPolicy), id);
    List<StorageTier> existingTierObjectsInDB = _dbClient.queryObject(StorageTier.class, tierUrisAssociatedWithPolicy);
    for (StorageTier tier : existingTierObjectsInDB) {
        if (!tierNativeGuidsfromProvider.contains(tier.getNativeGuid())) {
            if (null != tier.getAutoTieringPolicies()) {
                tier.getAutoTieringPolicies().clear();
            }
            _dbClient.updateAndReindexObject(tier);
        }
    }
}
Also used : StorageTier(com.emc.storageos.db.client.model.StorageTier) URI(java.net.URI)

Example 9 with StorageTier

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

the class VMAXTiersToPoolProcessor method addFastPolicyToTier.

@SuppressWarnings("unchecked")
private void addFastPolicyToTier(List<CIMObjectPath> policyPaths, String tierID) throws IOException {
    Set<String> policyUris = new StringSet();
    // getting policy uris from DB
    for (CIMObjectPath path : policyPaths) {
        String policyID = getFASTPolicyID(path);
        AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(policyID, _dbClient);
        if (null != policy) {
            policyUris.add(policy.getId().toString());
        }
    }
    StorageTier tierObject = checkStorageTierExistsInDB(getTierNativeGuidForVMax(tierID), _dbClient);
    if (null != tierObject) {
        if (null == tierObject.getAutoTieringPolicies()) {
            tierObject.setAutoTieringPolicies(new StringSet());
        }
        tierObject.getAutoTieringPolicies().replace(policyUris);
        _dbClient.updateAndReindexObject(tierObject);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) StringSet(com.emc.storageos.db.client.model.StringSet) CIMObjectPath(javax.cim.CIMObjectPath) StorageTier(com.emc.storageos.db.client.model.StorageTier)

Example 10 with StorageTier

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

the class HDSCommunicationInterface method processStoragePoolTiersInfo.

private void processStoragePoolTiersInfo(StorageSystem system, Pool pool) {
    String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, pool.getObjectID(), NativeGUIDGenerator.POOL);
    URIQueryResultList uriQueryResult = new URIQueryResultList();
    Set<String> tiersSet = new HashSet<String>();
    List<StorageTier> newTiers = new ArrayList<StorageTier>();
    List<StorageTier> updateTiers = new ArrayList<StorageTier>();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), uriQueryResult);
    StoragePool poolInDb = null;
    if (uriQueryResult.iterator().hasNext()) {
        poolInDb = _dbClient.queryObject(StoragePool.class, uriQueryResult.iterator().next());
        if (null == poolInDb) {
            return;
        }
    }
    for (StoragePoolTier tier : pool.getTiers()) {
        String tierNativeGuid = NativeGUIDGenerator.generateStorageTierNativeGuidForHDSTier(system, poolInDb.getNativeId(), tier.getTierID());
        StorageTier storageTier = checkStorageTierExistsInDB(tierNativeGuid);
        if (null == storageTier) {
            storageTier = new StorageTier();
            storageTier.setId(URIUtil.createId(StorageTier.class));
            storageTier.setDiskDriveTechnology(tier.getDiskType());
            storageTier.setLabel(tier.getObjectID());
            storageTier.setNativeGuid(tierNativeGuid);
            storageTier.setStorageDevice(system.getId());
            storageTier.setTotalCapacity(Long.parseLong(tier.getCapacityInKB()));
            newTiers.add(storageTier);
        }
        // @TODO check whether we are getting the right percentage.
        storageTier.setPercentage(tier.getUsageRate());
        tiersSet.add(storageTier.getId().toString());
        updateTiers.add(storageTier);
    }
    _dbClient.createObject(newTiers);
    _dbClient.persistObject(updateTiers);
    poolInDb.addTiers(tiersSet);
    _dbClient.persistObject(poolInDb);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StorageTier(com.emc.storageos.db.client.model.StorageTier) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StoragePoolTier(com.emc.storageos.hds.model.StoragePoolTier) HashSet(java.util.HashSet)

Aggregations

StorageTier (com.emc.storageos.db.client.model.StorageTier)17 URI (java.net.URI)7 ArrayList (java.util.ArrayList)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 MapStorageTier (com.emc.storageos.api.mapper.functions.MapStorageTier)3 AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)3 StorageTierList (com.emc.storageos.model.block.tier.StorageTierList)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 CIMInstance (javax.cim.CIMInstance)3 CIMObjectPath (javax.cim.CIMObjectPath)3 VNXeStorageTier (com.emc.storageos.vnxe.models.VNXeStorageTier)2 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 StringSet (com.emc.storageos.db.client.model.StringSet)1 StoragePoolTier (com.emc.storageos.hds.model.StoragePoolTier)1