Search in sources :

Example 56 with StoragePool

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

the class VirtualArrayService method getAutoTierPolicies.

/**
 * Get all Auto Tier policies associated with given VirtualArray which satisfies
 * poolType.
 * If provisionType is thick, then only TierPolicies which belongs to Thick Provisioning
 * will be returned.
 * If provisionType is thin, then only TierPolicies which belongs to
 * Thin Provisioning will be returned.
 * If provisionType is not specified, then all TierPolicies will be returned.
 * In addition to the above constraints, only policies which satisfy the following conditions gets returned
 * 1. AutoTiering should be enabled on top level StorageSystem, which these policies belong to
 * 2. Policy should be in enabled State.
 *
 * ProvisionType Values :
 * {
 * Thin
 * Thick
 * }
 *
 * @params QueryParam , which includes provisionType
 *         provisionType- Thin or Thick
 * @brief List VirtualArray auto tier policies for provision type
 * @return A reference to a AutoTierPolicy List specifying the id and self link
 *         for each policy
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/auto-tier-policies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.SYSTEM_ADMIN })
public AutoTierPolicyList getAutoTierPolicies(@PathParam("id") URI id, @QueryParam("provisioning_type") String provisionType, @QueryParam("unique_auto_tier_policy_names") Boolean uniquePolicyNames) {
    if (null == uniquePolicyNames) {
        uniquePolicyNames = false;
    }
    URIQueryResultList poolsInVirtualArray = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePoolsConstraint(id.toString()), poolsInVirtualArray);
    Iterator<StoragePool> poolIter = _dbClient.queryIterativeObjectField(StoragePool.class, "storageDevice", poolsInVirtualArray);
    Set<URI> systems = new HashSet<>();
    while (poolIter.hasNext()) {
        systems.add(poolIter.next().getStorageDevice());
    }
    Set<URI> autoTierPolicyURIs = new HashSet<URI>();
    for (URI systemId : systems) {
        URIQueryResultList result = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFASTPolicyConstraint(systemId), result);
        while (result.iterator().hasNext()) {
            URI policyURI = result.iterator().next();
            autoTierPolicyURIs.add(policyURI);
        }
    }
    return getAutoTierPolicies(provisionType, autoTierPolicyURIs, uniquePolicyNames);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 57 with StoragePool

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

the class VirtualArrayService method getVirtualArrayPools.

private Map<URI, List<StoragePool>> getVirtualArrayPools(List<URI> varrayIds, ObjectLocalCache cache) {
    Map<URI, List<StoragePool>> poolMap = new HashMap<>();
    for (URI varr : varrayIds) {
        List<StoragePool> poolList = poolMap.get(varr);
        if (poolList == null) {
            poolList = new ArrayList<>();
            poolMap.put(varr, poolList);
        }
        URIQueryResultList poolsQueryResult = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePoolsConstraint(varr.toString()), poolsQueryResult);
        Iterator<URI> poolItr = poolsQueryResult.iterator();
        while (poolItr.hasNext()) {
            StoragePool pool = cache.queryObject(StoragePool.class, poolItr.next());
            poolList.add(pool);
        }
    }
    return poolMap;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) VirtualArrayConnectivityList(com.emc.storageos.model.varray.VirtualArrayConnectivityList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) AttributeList(com.emc.storageos.model.varray.AttributeList) List(java.util.List) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualPoolList(com.emc.storageos.model.vpool.VirtualPoolList) NetworkList(com.emc.storageos.model.varray.NetworkList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 58 with StoragePool

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

the class VirtualArrayService method getAvailableAttributes.

/**
 * Finds the available attributes & its values in a varray. Ex: In a
 * varray, if a system supports raid_levels such as RAID1, RAID2 then
 * this API call provides the supported information.
 *
 * @param id the URN of a ViPR VirtualArray.
 * @brief List available attributes for VirtualArray
 * @return List available attributes for VirtualArray
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/available-attributes")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public AttributeList getAvailableAttributes(@PathParam("id") URI id) {
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntityNotNull(varray, id, isIdEmbeddedInURL(id));
    _log.info("Finding the available attributes for varray: {}", id);
    AttributeList list = new AttributeList();
    list.setVArrayId(id);
    ObjectLocalCache cache = new ObjectLocalCache(_dbClient);
    List<StoragePool> pools = getVirtualArrayPools(Arrays.asList(id), cache).get(id);
    Map<String, Set<String>> availableAttrs = _matcherFramework.getAvailableAttributes(id, pools, cache, AttributeMatcher.VPOOL_MATCHERS);
    cache.clearCache();
    for (Map.Entry<String, Set<String>> entry : availableAttrs.entrySet()) {
        list.getAttributes().add(new VirtualPoolAvailableAttributesResourceRep(entry.getKey(), entry.getValue()));
    }
    return list;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePool(com.emc.storageos.db.client.model.StoragePool) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPoolAvailableAttributesResourceRep(com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) AttributeList(com.emc.storageos.model.varray.AttributeList) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) Map(java.util.Map) HashMap(java.util.HashMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 59 with StoragePool

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

the class VirtualArrayService method getAutoTierPolicies.

/**
 * Get all Auto Tier policies for all VArrays for a given provisioning type.
 * If provisionType is thick, then only TierPolicies which belongs to Thick Provisioning
 * will be returned.
 * If provisionType is thin, then only TierPolicies which belongs to
 * Thin Provisioning will be returned.
 * If provisionType is not specified, then all TierPolicies will be returned.
 * In addition to the above constraints, only policies which satisfy the following conditions gets returned
 * 1. AutoTiering should be enabled on top level StorageSystem, which these policies belong to
 * 2. Policy should be in enabled State.
 *
 * ProvisionType Values :
 * {
 * Thin
 * Thick
 * }
 *
 * @params QueryParam , which includes provisionType
 *         provisionType- Thin or Thick
 * @brief List VirtualArray auto tier policies for provision type
 * @return A reference to a AutoTierPolicy List specifying the id and self link
 *         for each policy
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/auto-tier-policies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.SYSTEM_ADMIN })
public AutoTierPolicyList getAutoTierPolicies(@QueryParam("provisioning_type") String provisionType, @QueryParam("unique_auto_tier_policy_names") Boolean uniquePolicyNames, BulkIdParam param) {
    if (null == uniquePolicyNames) {
        uniquePolicyNames = false;
    }
    Set<URI> systems = new HashSet<>();
    for (URI id : param.getIds()) {
        URIQueryResultList poolsInVirtualArray = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePoolsConstraint(id.toString()), poolsInVirtualArray);
        Iterator<StoragePool> poolIter = _dbClient.queryIterativeObjectField(StoragePool.class, "storageDevice", poolsInVirtualArray);
        while (poolIter.hasNext()) {
            systems.add(poolIter.next().getStorageDevice());
        }
    }
    Set<URI> autoTierPolicyURIs = new HashSet<>();
    for (URI systemId : systems) {
        URIQueryResultList result = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFASTPolicyConstraint(systemId), result);
        while (result.iterator().hasNext()) {
            URI policyURI = result.iterator().next();
            autoTierPolicyURIs.add(policyURI);
        }
    }
    return getAutoTierPolicies(provisionType, autoTierPolicyURIs, uniquePolicyNames);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 60 with StoragePool

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

the class VirtualPoolService method checkPoolsWithResources.

/**
 * Check whether the pools with vpool resources are part of the assigned pools.
 * We should not allow removal of pools with resources.
 *
 * @param poolAssignmentChanges
 * @param vpool
 * @param dbClient
 */
public void checkPoolsWithResources(StoragePoolAssignmentChanges poolAssignmentChanges, VirtualPool vpool, DbClient dbClient) {
    Set<String> poolsToCheck = new StringSet();
    // Find the pools which need to be checked for resources.
    if (vpool.getMatchedStoragePools() == null) {
        throw APIException.badRequests.invalidParameterNoMatchingPoolsExistToAssignPools(vpool.getId());
    }
    Set<String> vPoolMatchedPools = (StringSet) vpool.getMatchedStoragePools().clone();
    if (vpool.getAssignedStoragePools() != null && !vpool.getAssignedStoragePools().isEmpty()) {
        vPoolMatchedPools.removeAll(vpool.getAssignedStoragePools());
    }
    if (poolAssignmentChanges != null && poolAssignmentChanges.getAdd() != null) {
        if (poolAssignmentChanges.getAdd().getStoragePools() != null && !poolAssignmentChanges.getAdd().getStoragePools().isEmpty()) {
            vPoolMatchedPools.removeAll(poolAssignmentChanges.getAdd().getStoragePools());
        }
    }
    poolsToCheck.addAll(vPoolMatchedPools);
    if (poolAssignmentChanges != null && poolAssignmentChanges.getRemove() != null) {
        if (poolAssignmentChanges.getRemove().getStoragePools() != null && !poolAssignmentChanges.getRemove().getStoragePools().isEmpty()) {
            poolsToCheck.addAll(poolAssignmentChanges.getRemove().getStoragePools());
        }
    }
    Set<String> resourcePools = getPoolsWithVPoolResources(vpool, poolsToCheck, dbClient);
    if (!resourcePools.isEmpty()) {
        Set<String> poolNames = new StringSet();
        for (String poolUri : resourcePools) {
            StoragePool pool = dbClient.queryObject(StoragePool.class, URI.create(poolUri));
            poolNames.add(pool.getPoolName());
        }
        throw APIException.badRequests.cannotRemovePoolWithResources(poolNames);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30