Search in sources :

Example 1 with AutoTierPolicyList

use of com.emc.storageos.model.block.tier.AutoTierPolicyList in project coprhd-controller by CoprHD.

the class AutoTieringService method getAutoTierPolicies.

/**
 * @param provisionType The provisioning type associated with this policy [Thin,Thick or All]
 * @param uniquePolicyNames If unique_auto_tier_policy_names is set to true, then unique auto tier policy Names alone without any
 *            storage system details will be returned,
 *            even if the same policy exists in multiple arrays. If unique_auto_tier_policy_names is set to false, then duplicate policy
 *            names, with the storage system details, are returned
 *
 * @prereq none
 * @brief List all auto tier policies
 * @return AutoTierPolicyList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public AutoTierPolicyList getAutoTierPolicies(@QueryParam("provisioning_type") String provisionType, @QueryParam("unique_auto_tier_policy_names") Boolean uniquePolicyNames) {
    if (null == uniquePolicyNames) {
        uniquePolicyNames = false;
    }
    AutoTierPolicyList policyList = new AutoTierPolicyList();
    List<URI> policyUris = _dbClient.queryByType(AutoTieringPolicy.class, true);
    List<AutoTieringPolicy> policies = _dbClient.queryObject(AutoTieringPolicy.class, policyUris);
    for (AutoTieringPolicy policy : policies) {
        if (!doesGivenProvisionTypeMatchAutoTierPolicy(provisionType, policy)) {
            continue;
        }
        BlockMapper.addAutoTierPolicy(policy, 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) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with AutoTierPolicyList

use of com.emc.storageos.model.block.tier.AutoTierPolicyList in project coprhd-controller by CoprHD.

the class VirtualArrayService method getAutoTierPolicies.

/**
 * get Policies which satisfy the below
 * 1. if policy is enabled
 * 2. if is enabled on associated Storage System.
 * 3. Policy's provisioning Type equals given provisioningType
 */
private AutoTierPolicyList getAutoTierPolicies(String provisionType, Set<URI> autoTierPolicyUris, boolean uniquePolicyNames) {
    AutoTierPolicyList result = new AutoTierPolicyList();
    List<URI> autoTierPolicyUriList = new ArrayList<>(autoTierPolicyUris);
    Iterator<AutoTieringPolicy> autoTierPolicies = _dbClient.queryIterativeObjects(AutoTieringPolicy.class, autoTierPolicyUriList, true);
    Map<URI, StorageSystem> systemCache = new HashMap<>();
    while (autoTierPolicies.hasNext()) {
        AutoTieringPolicy policy = autoTierPolicies.next();
        // If policy is disabled, skip it
        if (!policy.getPolicyEnabled()) {
            continue;
        }
        if (!doesGivenProvisionTypeMatchAutoTierPolicy(provisionType, policy)) {
            continue;
        }
        StorageSystem system = systemCache.get(policy.getStorageSystem());
        if (system == null) {
            system = _dbClient.queryObject(StorageSystem.class, policy.getStorageSystem());
            systemCache.put(policy.getStorageSystem(), system);
        }
        // if is disabled then skip it too.
        if (null != system && system.getAutoTieringEnabled()) {
            addAutoTierPolicy(policy, result, uniquePolicyNames);
        }
    }
    return result;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with AutoTierPolicyList

use of com.emc.storageos.model.block.tier.AutoTierPolicyList in project coprhd-controller by CoprHD.

the class AutoTieringPolicies method getByVirtualArrays.

/**
 * Gets all auto tier policies for all virtual arrays.
 *
 * @param virtualArrayIds
 *            the ID of the virtual array.
 * @param provisioningType
 *            the provisioning type, if null matches any provisioning type.
 * @param uniqueNames
 *            when true duplicate named policies will be ignored.
 * @param filter
 * @return the list of auto tier policies.
 *
 * @see #getByRefs(java.util.Collection)
 * @see VirtualArrays
 */
public List<AutoTieringPolicyRestRep> getByVirtualArrays(Collection<URI> virtualArrayIds, String provisioningType, Boolean uniqueNames, ResourceFilter<AutoTieringPolicyRestRep> filter) {
    UriBuilder builder = client.uriBuilder(PathConstants.AUTO_TIER_FOR_ALL_VARRAY);
    if ((provisioningType != null) && (provisioningType.length() > 0)) {
        builder.queryParam("provisioning_type", provisioningType);
    }
    if (uniqueNames != null) {
        builder.queryParam("unique_auto_tier_policy_names", uniqueNames);
    }
    BulkIdParam input = new BulkIdParam((List<URI>) virtualArrayIds);
    AutoTierPolicyList response = client.postURI(AutoTierPolicyList.class, input, builder.build());
    return defaultList(getByRefs(response.getAutoTierPolicies(), filter));
}
Also used : AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkIdParam(com.emc.storageos.model.BulkIdParam) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI)

Example 4 with AutoTierPolicyList

use of com.emc.storageos.model.block.tier.AutoTierPolicyList 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)

Aggregations

AutoTierPolicyList (com.emc.storageos.model.block.tier.AutoTierPolicyList)4 URI (java.net.URI)4 AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BulkIdParam (com.emc.storageos.model.BulkIdParam)1 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1