Search in sources :

Example 1 with StoragePoolResources

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

the class StoragePoolService method getStoragePoolResources.

/**
 * Retrieves the id, name, and type of the resources in the registered
 * storage pool. with the passed id.
 *
 * @param id the URN of a ViPR storage pool.
 *
 * @brief List storage pool resources
 * @return A list of the resources in the storage pool.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/resources")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePoolResources getStoragePoolResources(@PathParam("id") URI id) {
    // Make sure the storage pool is registered.
    ArgValidator.checkFieldUriType(id, StoragePool.class, "id");
    queryRegisteredResource(id);
    // Create the storage pools resources to be returned.
    StoragePoolResources resources = new StoragePoolResources();
    // Get the active volumes in the storage pool and add them to
    // the storage pool resources
    URIQueryResultList volumeURIList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolVolumeConstraint(id), volumeURIList);
    Iterator<URI> volumeURIIter = volumeURIList.iterator();
    while (volumeURIIter.hasNext()) {
        URI volumeURI = volumeURIIter.next();
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        if ((volume != null) && (!volume.getInactive())) {
            TypedRelatedResourceRep resource = toTypedRelatedResource(volume);
            resources.getResources().add(resource);
        }
    }
    // Get the active file shares in the storage pool and add them to the
    // storage pools resources.
    URIQueryResultList fsURIList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolFileshareConstraint(id), fsURIList);
    Iterator<URI> fsURIIter = fsURIList.iterator();
    while (fsURIIter.hasNext()) {
        URI fsURI = fsURIIter.next();
        FileShare fs = _dbClient.queryObject(FileShare.class, fsURI);
        if ((fs != null) && (!fs.getInactive())) {
            TypedRelatedResourceRep resource = toTypedRelatedResource(fs);
            resources.getResources().add(resource);
        }
    }
    return resources;
}
Also used : TypedRelatedResourceRep(com.emc.storageos.model.TypedRelatedResourceRep) StoragePoolResources(com.emc.storageos.model.pools.StoragePoolResources) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) 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)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 Volume (com.emc.storageos.db.client.model.Volume)1 TypedRelatedResourceRep (com.emc.storageos.model.TypedRelatedResourceRep)1 StoragePoolResources (com.emc.storageos.model.pools.StoragePoolResources)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1