Search in sources :

Example 16 with AutoTieringPolicy

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

the class FASTPolicyProcessor method createFASTPolicy.

/**
 * create FAST Policy Object
 * s
 *
 * @param policyName
 * @param policy
 * @throws IOException
 */
private void createFASTPolicy(String policyID, AutoTieringPolicy policy, String policyRuleName, URI storageSystemURI, String policyEnabled, String provisioningType) throws IOException {
    boolean newPolicy = false;
    if (null == policy) {
        newPolicy = true;
        policy = new AutoTieringPolicy();
        policy.setId(URIUtil.createId(AutoTieringPolicy.class));
        policy.setStorageSystem(storageSystemURI);
        policy.setNativeGuid(policyID);
        policy.setSystemType(getDeviceType(storageSystemURI));
    }
    policy.setLabel(policyRuleName);
    policy.setPolicyName(policyRuleName);
    policy.setPolicyEnabled(policyEnabled.equalsIgnoreCase("1"));
    policy.setProvisioningType(provisioningType);
    if (newPolicy) {
        _newFastPolicies.add(policy);
    } else {
        _updateFastPolicies.add(policy);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy)

Example 17 with AutoTieringPolicy

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

the class PersistFASTPolicyProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        List<AutoTieringPolicy> fastPolicies = new ArrayList<AutoTieringPolicy>();
        @SuppressWarnings("unchecked") Map<String, Set<String>> mapping = (Map<String, Set<String>>) keyMap.get(Constants.POLICY_TO_POOLS_MAPPING);
        for (String key : mapping.keySet()) {
            AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(key, _dbClient);
            Set<String> pools = mapping.get(key);
            policy.addPools(pools);
            fastPolicies.add(policy);
        }
        _dbClient.persistObject(fastPolicies);
    } catch (Exception e) {
        _logger.error("Adding Pools to POlicy Objects and Persisting failed :", e);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) Set(java.util.Set) ArrayList(java.util.ArrayList) Map(java.util.Map) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 18 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy 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 19 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy 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 20 with AutoTieringPolicy

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

the class StorageScheduler method getAutoTierPolicy.

/**
 * Get the AutoTierPolicy URI for a given StoragePool and auto tier policy name.
 *
 * @param pool
 *            -- Storage Pool URI
 * @param policyName
 *            -- Policy name
 * @param dbClient
 * @return URI of AutoTierPolicy, null if not found
 */
public static URI getAutoTierPolicy(URI pool, String policyName, DbClient dbClient) {
    if (pool == null || policyName == null || dbClient == null) {
        return null;
    }
    URIQueryResultList result = new URIQueryResultList();
    // check if pool fast policy name is not
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFASTPolicyByNameConstraint(policyName), result);
    Iterator<URI> iterator = result.iterator();
    while (iterator.hasNext()) {
        AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, iterator.next());
        if (null == policy.getStorageSystem()) {
            continue;
        }
        // pool's storage system
        // Note that the pool can be null when the function is called while
        // preparing a VPLEX volume, which does not have a storage pool.
        StoragePool poolObj = dbClient.queryObject(StoragePool.class, pool);
        if ((poolObj != null) && (policy.getStorageSystem().toString().equalsIgnoreCase(poolObj.getStorageDevice().toString()))) {
            return policy.getId();
        }
    }
    return null;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)37 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 URI (java.net.URI)18 ArrayList (java.util.ArrayList)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 HashSet (java.util.HashSet)6 List (java.util.List)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 HashMap (java.util.HashMap)4 CIMObjectPath (javax.cim.CIMObjectPath)4 StorageTier (com.emc.storageos.db.client.model.StorageTier)3 AutoTierPolicyList (com.emc.storageos.model.block.tier.AutoTierPolicyList)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 Volume (com.emc.storageos.db.client.model.Volume)2 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 CIMInstance (javax.cim.CIMInstance)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1