Search in sources :

Example 36 with AutoTieringPolicy

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;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 37 with AutoTieringPolicy

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;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) StringSet(com.emc.storageos.db.client.model.StringSet) 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