Search in sources :

Example 1 with VolumeTypesRestResp

use of com.emc.storageos.cinder.model.VolumeTypesRestResp in project coprhd-controller by CoprHD.

the class TypeService method getVolumeTypes.

/**
 * Get volume types
 *
 * @prereq none
 *
 * @param tenant_id the URN of the tenant
 *
 * @brief List volume types
 * @return Volume types list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getVolumeTypes(@PathParam("tenant_id") URI openstack_tenant_id, @Context HttpHeaders header) {
    // Here we ignore the openstack tenant id
    _log.info("START get list of volume types");
    VolumeTypesRestResp types = new VolumeTypesRestResp();
    StorageOSUser user = getUserFromContext();
    URI tenantId = URI.create(user.getTenantId());
    List<URI> vpools = _dbClient.queryByType(VirtualPool.class, true);
    for (URI vpool : vpools) {
        VirtualPool pool = _dbClient.queryObject(VirtualPool.class, vpool);
        _log.debug("Looking up vpool {}", pool.getLabel());
        if (pool != null && pool.getType().equalsIgnoreCase(VirtualPool.Type.block.name())) {
            if (_permissionsHelper.tenantHasUsageACL(tenantId, pool)) {
                _log.debug("Adding vpool {}", pool.getLabel());
                VolumeType type = new VolumeType();
                type.id = pool.getId().toString();
                type.name = pool.getLabel();
                type.extra_specs = new HashMap<String, String>();
                types.getVolume_types().add(type);
            }
        }
    }
    _log.info("END get list of volume types");
    return CinderApiUtils.getCinderResponse(types, header, false, CinderConstants.STATUS_OK);
}
Also used : VolumeType(com.emc.storageos.cinder.model.VolumeType) VolumeTypesRestResp(com.emc.storageos.cinder.model.VolumeTypesRestResp) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

VolumeType (com.emc.storageos.cinder.model.VolumeType)1 VolumeTypesRestResp (com.emc.storageos.cinder.model.VolumeTypesRestResp)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1