use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.
the class StorageSystemService method getAllFastPolicies.
/**
* Gets all AutoTier policies associated with registered storage system with the passed
* id. Only policies which satisfy the below will be returned
* 1. AutoTiering should be enabled on StorageSystem
* 2. AutoTierPolicy should be in Enabled State.
*
* @param id the URN of a ViPR storage system.
* @brief List storage system autotier policies
* @return A reference to a AutoTierPolicy List specifying the id and self link
* for each storage pool.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/auto-tier-policies")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public AutoTierPolicyList getAllFastPolicies(@PathParam("id") URI id, @QueryParam("unique_policy_names") Boolean uniquePolicyNames) {
// Make sure storage system is registered.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryRegisteredSystem(id);
if (!system.getAutoTieringEnabled()) {
throw APIException.badRequests.autoTieringNotEnabledOnStorageSystem(id);
}
if (uniquePolicyNames == null) {
uniquePolicyNames = false;
}
AutoTierPolicyList policyList = new AutoTierPolicyList();
URIQueryResultList fastPolicyURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFASTPolicyConstraint(id), fastPolicyURIs);
Iterator<URI> fastPolicyIterator = fastPolicyURIs.iterator();
while (fastPolicyIterator.hasNext()) {
URI fastPolicyURI = fastPolicyIterator.next();
AutoTieringPolicy fastPolicy = _dbClient.queryObject(AutoTieringPolicy.class, fastPolicyURI);
if (null != fastPolicy && fastPolicy.getPolicyEnabled()) {
addAutoTierPolicy(fastPolicy, policyList, uniquePolicyNames);
}
}
return policyList;
}
use of com.emc.storageos.db.client.model.AutoTieringPolicy in project coprhd-controller by CoprHD.
the class ControllerUtils method getAutoTieringPolicyURIFromVirtualPool.
/**
* Gets the URI of auto tiering policy associated with from virtual pool.
*
* @param vPool the virtual pool
* @param storage the storage system
* @param dbClient the db client
* @return the auto tiering policy uri
*/
public static URI getAutoTieringPolicyURIFromVirtualPool(VirtualPool vPool, StorageSystem storage, DbClient dbClient) {
/**
* for VMAX:
* if unique tiering policy is enabled on Virtual Pool, it has policy's
* name. else it has policy's nativeGuid.
*
* for VNX:
* Unique tiering policy field is not available.
* So, it always has the policy's name.
*/
String policyNameInVpool = vPool.getAutoTierPolicyName();
if (policyNameInVpool != null) {
URIQueryResultList result = new URIQueryResultList();
if (vPool.getUniquePolicyNames()) {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFASTPolicyByNameConstraint(policyNameInVpool), result);
} else {
StringSet systemType = new StringSet();
if (vPool.getArrayInfo() != null) {
systemType.addAll(vPool.getArrayInfo().get(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE));
}
if (systemType.contains(DiscoveredDataObject.Type.vnxblock.name())) {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFASTPolicyByNameConstraint(policyNameInVpool), result);
} else {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getAutoTieringPolicyByNativeGuidConstraint(policyNameInVpool), result);
}
}
Iterator<URI> iterator = result.iterator();
// policies with that name from different arrays.
while (iterator.hasNext()) {
URI policyURI = iterator.next();
AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
if (policy.getStorageSystem().equals(storage.getId())) {
return policyURI;
}
}
}
return null;
}
Aggregations