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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations