Search in sources :

Example 1 with VolumeType

use of com.emc.storageos.cinder.model.VolumeType 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)

Example 2 with VolumeType

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

the class TypeService method getVolumeType.

/**
 * Get information about a specified volume type
 *
 * @prereq none
 *
 * @param tenant_id the URN of the tenant
 * @param volume_type_id the URN of the volume type
 *
 * @brief Show volume type
 * @return Volume type details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{volume_type_id}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public Response getVolumeType(@PathParam("tenant_id") URI openstacktenant_id, @PathParam("volume_type_id") URI volume_type_id, @Context HttpHeaders header) {
    _log.debug("START get volume types {}", volume_type_id);
    // Here we ignore the openstack tenant id
    VolumeType volType = new VolumeType();
    VirtualPool pool = _dbClient.queryObject(VirtualPool.class, volume_type_id);
    if (pool != null) {
        if (pool.getType().equalsIgnoreCase(VirtualPool.Type.block.name())) {
            _log.debug("Found matching vpool {}", pool.getLabel());
            StorageOSUser user = getUserFromContext();
            URI tenantId = URI.create(user.getTenantId());
            if (_permissionsHelper.tenantHasUsageACL(tenantId, pool)) {
                _log.debug("Has permissions for vpool {}", pool.getLabel());
                volType.id = pool.getId().toString();
                volType.name = pool.getLabel();
                volType.extra_specs = new HashMap<String, String>();
            }
        }
    }
    _log.debug("END get volume types {}", volume_type_id);
    return CinderApiUtils.getCinderResponse(volType, header, true, CinderConstants.STATUS_OK);
}
Also used : VolumeType(com.emc.storageos.cinder.model.VolumeType) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

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