Search in sources :

Example 26 with AutoTieringPolicy

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

the class AutoTieringPolicyMatcher method getAutoTieringPoolsOnVMAX.

/**
 * Get all storagepools associated with all the policies based on the policy name passed.
 *
 * @param policyName
 * @return
 */
private Set<String> getAutoTieringPoolsOnVMAX(String policyName, Map<String, Object> attributeMap) {
    Set<String> fastPolicyPools = new HashSet<String>();
    URIQueryResultList result = getAutoTierPolicies(attributeMap, policyName);
    Iterator<URI> iterator = result.iterator();
    while (iterator.hasNext()) {
        AutoTieringPolicy policy = _objectCache.queryObject(AutoTieringPolicy.class, iterator.next());
        if (isValidAutoTieringPolicy(policy) && isAutoTieringEnabledOnStorageSystem(policy.getStorageSystem()) && doesGivenProvisionTypeMatchFastPolicy(attributeMap.get(Attributes.provisioning_type.toString()).toString(), policy)) {
            if (null != policy.getPools()) {
                fastPolicyPools.addAll(policy.getPools());
            }
        }
    }
    return fastPolicyPools;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 27 with AutoTieringPolicy

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

the class AutoTieringPolicyMatcher method getAutoTieringPoolsOnExternalSystem.

/**
 * Filter the passed list of storage pools to only those that match the passed auto tiering policy.
 *
 * @param policyName The auto tiering policy name.
 * @param attributeMap The matcher attribute map.
 * @param pools The complete list of pools to be filtered.
 *
 * @return The filtered list of pools matching the policy with the passed name.
 */
private List<StoragePool> getAutoTieringPoolsOnExternalSystem(String policyName, Map<String, Object> attributeMap, List<StoragePool> pools) {
    Set<String> policyPools = new HashSet<String>();
    URIQueryResultList result = getAutoTierPolicies(attributeMap, policyName);
    Iterator<URI> iterator = result.iterator();
    while (iterator.hasNext()) {
        AutoTieringPolicy policy = _objectCache.queryObject(AutoTieringPolicy.class, iterator.next());
        if (isValidAutoTieringPolicy(policy) && isAutoTieringEnabledOnStorageSystem(policy.getStorageSystem()) && doesGivenProvisionTypeMatchFastPolicy(attributeMap.get(Attributes.provisioning_type.toString()).toString(), policy)) {
            if (null != policy.getPools()) {
                policyPools.addAll(policy.getPools());
            }
        }
    }
    List<StoragePool> filteredPools = new ArrayList<StoragePool>();
    Iterator<StoragePool> poolIterator = pools.iterator();
    while (poolIterator.hasNext()) {
        StoragePool pool = poolIterator.next();
        // if it doesn't match remove it from all pools.
        if (policyPools.contains(pool.getId().toString())) {
            filteredPools.add(pool);
        } else {
            _logger.info("Ignoring pool {} as it doesn't belongs to FAST policy.", pool.getNativeGuid());
        }
    }
    return filteredPools;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 28 with AutoTieringPolicy

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

the class VNXeCommunicationInterface method discoverAutoTierPolicies.

private HashMap<String, List<AutoTieringPolicy>> discoverAutoTierPolicies(StorageSystem system, VNXeApiClient apiClient) {
    HashMap<String, List<AutoTieringPolicy>> policies = new HashMap<String, List<AutoTieringPolicy>>();
    List<AutoTieringPolicy> newPolicies = new ArrayList<AutoTieringPolicy>();
    List<AutoTieringPolicy> updatePolicies = new ArrayList<AutoTieringPolicy>();
    String[] tierPolicies = apiClient.getAutoTierPolicies();
    String systemNativeGuid = NativeGUIDGenerator.generateNativeGuid(system);
    for (String policyName : tierPolicies) {
        String policyNativeGuid = NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(systemNativeGuid, policyName, NativeGUIDGenerator.FASTPOLICY);
        URIQueryResultList result = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getAutoTieringPolicyByNativeGuidConstraint(policyNativeGuid), result);
        AutoTieringPolicy policy = null;
        if (result.iterator().hasNext()) {
            policy = _dbClient.queryObject(AutoTieringPolicy.class, result.iterator().next());
        }
        boolean newPolicy = false;
        if (null == policy) {
            newPolicy = true;
            policy = new AutoTieringPolicy();
            policy.setId(URIUtil.createId(AutoTieringPolicy.class));
            policy.setStorageSystem(system.getId());
            policy.setNativeGuid(policyNativeGuid);
            policy.setSystemType(system.getSystemType());
        }
        policy.setLabel(policyName);
        policy.setPolicyName(policyName);
        policy.setPolicyEnabled(true);
        policy.setProvisioningType(AutoTieringPolicy.ProvisioningType.All.name());
        if (newPolicy) {
            newPolicies.add(policy);
        } else {
            updatePolicies.add(policy);
        }
    }
    policies.put(NEW, newPolicies);
    policies.put(EXISTING, updatePolicies);
    return policies;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 29 with AutoTieringPolicy

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

the class ControllerUtils method getFastPolicyNameFromVirtualPool.

/**
 * Convenient method to get policy name from a virtual pool
 *
 * @param _dbClient
 * @param storage
 * @param vpool
 * @return
 */
public static String getFastPolicyNameFromVirtualPool(DbClient _dbClient, StorageSystem storage, VirtualPool vpool) {
    String policyName = Constants.NONE;
    URI policyURI = ControllerUtils.getAutoTieringPolicyURIFromVirtualPool(vpool, storage, _dbClient);
    if (policyURI != null) {
        AutoTieringPolicy policy = _dbClient.queryObject(AutoTieringPolicy.class, policyURI);
        policyName = policy.getPolicyName();
    }
    return policyName;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) URI(java.net.URI)

Example 30 with AutoTieringPolicy

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

the class AutoTieringPolicyProcessorHelper method getAutoTieringPolicyByNameFromDB.

/**
 * Look up AutoTieringPolicy object by the given policyID. If found, return it, otherwise return null
 *
 * @param policyID [in] - Identifier for the policy
 * @param dbClient [in] - Database client
 * @return
 */
public static AutoTieringPolicy getAutoTieringPolicyByNameFromDB(String policyID, DbClient dbClient) {
    AutoTieringPolicy policy = null;
    try {
        URIQueryResultList result = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getAutoTieringPolicyByNativeGuidConstraint(policyID), result);
        while (result.iterator().hasNext()) {
            policy = dbClient.queryObject(AutoTieringPolicy.class, result.iterator().next());
        }
    } catch (Exception e) {
        logger.error("AutoTieringPolicy retrieval from DB failed", e);
    }
    return policy;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) 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