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);
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations