Search in sources :

Example 1 with AutoTieringPolicy

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

the class ControllerUtils method getAutoTieringPolicyName.

public static String getAutoTieringPolicyName(URI uri, DbClient dbClient) {
    String policyName = Constants.NONE;
    if (URIUtil.isType(uri, Volume.class)) {
        Volume volume = dbClient.queryObject(Volume.class, uri);
        URI policyURI = volume.getAutoTieringPolicyUri();
        if (!NullColumnValueGetter.isNullURI(policyURI)) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
            policyName = policy.getPolicyName();
        }
    } else if (URIUtil.isType(uri, BlockSnapshot.class)) {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, uri);
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, snapshot.getStorageController());
        if (storage.checkIfVmax3()) {
            Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
            URI policyURI = volume.getAutoTieringPolicyUri();
            if (!NullColumnValueGetter.isNullURI(policyURI)) {
                AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
                policyName = policy.getPolicyName();
            }
        }
    } else if (URIUtil.isType(uri, BlockMirror.class)) {
        BlockMirror mirror = dbClient.queryObject(BlockMirror.class, uri);
        if (!NullColumnValueGetter.isNullURI(mirror.getAutoTieringPolicyUri())) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, mirror.getAutoTieringPolicyUri());
            policyName = policy.getPolicyName();
        }
    }
    return policyName;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with AutoTieringPolicy

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

the class VirtualPoolUtil method isAutoTieringPolicyValidForDeviceType.

public static boolean isAutoTieringPolicyValidForDeviceType(String autoTierPolicyName, String systemType, DbClient dbClient) {
    if (null == autoTierPolicyName || autoTierPolicyName.equalsIgnoreCase("NONE")) {
        return true;
    }
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFASTPolicyByNameConstraint(autoTierPolicyName), result);
    while (result.iterator().hasNext()) {
        AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, result.iterator().next());
        if (policy == null) {
            continue;
        }
        if (systemType.equalsIgnoreCase(policy.getSystemType())) {
            return true;
        }
    }
    return false;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with AutoTieringPolicy

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

the class AutoTieringService method getStorageTiersForGivenPolicy.

/**
 * Show the storage tiers associated with a specific auto tiering policy
 * Only auto tiering policies belonging to VMAX systems have direct association to tiers.
 *
 * @param id the URN of a ViPR auto tier policy
 *
 * @prereq none
 * @brief List storage tiers for auto tiering policy
 * @return Policy Object
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/storage-tiers")
public StorageTierList getStorageTiersForGivenPolicy(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, AutoTieringPolicy.class, "id");
    AutoTieringPolicy policy = _dbClient.queryObject(AutoTieringPolicy.class, id);
    ArgValidator.checkEntityNotNull(policy, id, isIdEmbeddedInURL(id));
    StorageTierList storageTierList = new StorageTierList();
    List<URI> tierUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageTierFASTPolicyConstraint(policy.getId().toString()));
    List<StorageTier> tiers = _dbClient.queryObject(StorageTier.class, tierUris);
    for (StorageTier tier : tiers) {
        storageTierList.getStorageTiers().add(toNamedRelatedResource(tier, tier.getNativeGuid()));
    }
    return storageTierList;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) StorageTier(com.emc.storageos.db.client.model.StorageTier) StorageTierList(com.emc.storageos.model.block.tier.StorageTierList) URI(java.net.URI) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with AutoTieringPolicy

use of com.emc.storageos.db.client.model.AutoTieringPolicy 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 5 with AutoTieringPolicy

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

the class AutoTieringService method getAutoTierPolicy.

/**
 * Show the specified auto tiering policy.
 *
 * @param id the URN of a ViPR auto tier policy
 * @prereq none
 * @brief Show the details of the specified auto tiering policy
 * @return Policy Object
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}")
public AutoTieringPolicyRestRep getAutoTierPolicy(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, AutoTieringPolicy.class, "id");
    AutoTieringPolicy policy = _dbClient.queryObject(AutoTieringPolicy.class, id);
    ArgValidator.checkEntityNotNull(policy, id, isIdEmbeddedInURL(id));
    return map(policy);
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

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