Search in sources :

Example 6 with StoragePoolList

use of com.emc.storageos.model.pools.StoragePoolList in project coprhd-controller by CoprHD.

the class VirtualArrayService method getVirtualArrayStoragePools.

/**
 * Returns the storage pools for the VirtualArray with the passed id. When
 * the VirtualArray has been explicitly assigned to one or more storage
 * pools, this API will return the ids of those storage pools. VirtualArrays
 * can be explicitly assigned to storage pools when a storage pool is
 * created or later by modifying the storage pool after it has been created.
 * <p>
 * Whether or not a VirtualArray has been explicitly assigned to any storage pools the VirtualArray may still have implicit associations
 * with one or more storage pools due to the VirtualArray's network connectivity. That is, a network resides in a VirtualArray and may
 * contain storage ports. This implies that these storage ports reside in the VirtualArray, which further implies that the storage
 * system and any storage pools on that storage system also reside in the VirtualArray. If the VirtualArray has no explicit assignments,
 * but does have implicit associations, the API will instead return those storage pools implicitly associated.
 * <p>
 * The API provides the ability to force the return of the list of storage pools implicitly associated with the VirtualArray using the
 * request parameter "network_connectivity". Passing this parameter with a value of "true" will return the ids of the storage pools
 * implicitly associated with the VirtualArray as described.
 *
 * @param id the URN of a ViPR VirtualArray.
 * @param useNetworkConnectivity true to use the network connectivity to
 *            get the list of storage pools implicitly connected to the
 *            VirtualArray.
 *
 * @brief List VirtualArray storage pools
 * @return The ids of the storage pools associated with the VirtualArray.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-pools")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public StoragePoolList getVirtualArrayStoragePools(@PathParam("id") URI id, @QueryParam("network_connectivity") boolean useNetworkConnectivity) {
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
    // Query the database for the storage pools associated with the
    // VirtualArray. If the request is for storage pools whose
    // association with the VirtualArray is implicit through network
    // connectivity, then return only these storage pools.
    // Otherwise, the result is for storage pools explicitly assigned
    // to the VirtualArray.
    URIQueryResultList storagePoolURIs = new URIQueryResultList();
    if (useNetworkConnectivity) {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getImplicitVirtualArrayStoragePoolsConstraint(id.toString()), storagePoolURIs);
    } else {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePoolsConstraint(id.toString()), storagePoolURIs);
    }
    // Create and return the result.
    StoragePoolList storagePools = new StoragePoolList();
    for (URI uri : storagePoolURIs) {
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, uri);
        if ((storagePool != null) && (CompatibilityStatus.COMPATIBLE.toString().equals(storagePool.getCompatibilityStatus())) && (RegistrationStatus.REGISTERED.toString().equals(storagePool.getRegistrationStatus())) && DiscoveryStatus.VISIBLE.toString().equals(storagePool.getDiscoveryStatus())) {
            storagePools.getPools().add(toNamedRelatedResource(storagePool, storagePool.getNativeGuid()));
        }
    }
    return storagePools;
}
Also used : StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with StoragePoolList

use of com.emc.storageos.model.pools.StoragePoolList in project coprhd-controller by CoprHD.

the class VirtualPoolService method getStoragePoolsForVirtualPool.

/**
 * Determines the storage pools the satisfy the VirtualPool with the passed URI.
 * This method returns the pools which are valid means the pools will be
 * used for placement. Pools will be returned based on the
 * useMatchedStoragePools flag. if useMatchedStoragePools = true, returns
 * the matched storage pools. else returns assigned storage pools. after
 * that, we should remove the invalid matched pools from matched/assigned
 * pool if there are any such pools exists. valid Pools =
 * (matchedStoragePools/assignedStoragePools - invalidMatchedPools)
 *
 * @param id the URN of a ViPR VirtualPool.
 * @return A reference to a VirtualPoolStoragePool, which contains a list of the URIs
 *         of the storage pools that satisfy the VirtualPool.
 */
protected StoragePoolList getStoragePoolsForVirtualPool(URI id) {
    // Get the vpool with the passed id.
    ArgValidator.checkUri(id);
    StoragePoolList poolList = new StoragePoolList();
    VirtualPool vpool = queryResource(id);
    ArgValidator.checkEntity(vpool, id, isIdEmbeddedInURL(id));
    List<StoragePool> validPools = VirtualPool.getValidStoragePools(vpool, _dbClient, false);
    Iterator<StoragePool> poolIterator = validPools.iterator();
    while (poolIterator.hasNext()) {
        StoragePool pool = poolIterator.next();
        poolList.getPools().add(toNamedRelatedResource(pool, pool.getNativeGuid()));
    }
    return poolList;
}
Also used : StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 8 with StoragePoolList

use of com.emc.storageos.model.pools.StoragePoolList in project coprhd-controller by CoprHD.

the class StorageSystemService method getAllStoragePools.

/**
 * Gets all storage pools for the registered storage system with the passed
 * id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief List storage system storage pools
 * @return A reference to a StoragePooList specifying the id and self link
 *         for each storage pool.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-pools")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePoolList getAllStoragePools(@PathParam("id") URI id) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    StoragePoolList poolList = new StoragePoolList();
    URIQueryResultList storagePoolURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(id), storagePoolURIs);
    Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
    while (storagePoolIter.hasNext()) {
        URI storagePoolURI = storagePoolIter.next();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
        if (storagePool != null && !storagePool.getInactive()) {
            poolList.getPools().add(toNamedRelatedResource(storagePool, storagePool.getNativeGuid()));
        }
    }
    return poolList;
}
Also used : StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) StoragePool(com.emc.storageos.db.client.model.StoragePool) 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

StoragePool (com.emc.storageos.db.client.model.StoragePool)8 StoragePoolList (com.emc.storageos.model.pools.StoragePoolList)8 URI (java.net.URI)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Produces (javax.ws.rs.Produces)6 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)5 Path (javax.ws.rs.Path)5 Consumes (javax.ws.rs.Consumes)3 GET (javax.ws.rs.GET)3 POST (javax.ws.rs.POST)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)1 VirtualPoolMapper.toFileVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toFileVirtualPool)1 VirtualPoolMapper.toObjectVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toObjectVirtualPool)1 MapFileVirtualPool (com.emc.storageos.api.mapper.functions.MapFileVirtualPool)1 MapObjectVirtualPool (com.emc.storageos.api.mapper.functions.MapObjectVirtualPool)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1