Search in sources :

Example 11 with HostList

use of com.emc.storageos.model.host.HostList in project coprhd-controller by CoprHD.

the class HostService method listHosts.

/**
 * Lists the id and name for all the hosts that belong to the given tenant organization.
 *
 * @param tid
 *            the URN of a ViPR tenant organization
 * @prereq none
 * @brief List hosts
 * @return a list of hosts that belong to the tenant organization.
 * @throws DatabaseException
 *             when a DB error occurs
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList listHosts(@QueryParam("tenant") final URI tid) throws DatabaseException {
    URI tenantId;
    StorageOSUser user = getUserFromContext();
    if (tid == null || StringUtils.isBlank(tid.toString())) {
        tenantId = URI.create(user.getTenantId());
    } else {
        tenantId = tid;
    }
    // this call validates the tenant id
    TenantOrg tenant = _permissionsHelper.getObjectById(tenantId, TenantOrg.class);
    ArgValidator.checkEntity(tenant, tenantId, isIdEmbeddedInURL(tenantId), true);
    // check the user permissions for this tenant org
    verifyAuthorizedInTenantOrg(tenantId, user);
    // get all host children
    HostList list = new HostList();
    list.setHosts(map(ResourceTypeEnum.HOST, listChildren(tenantId, Host.class, "label", "tenant")));
    return list;
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) HostList(com.emc.storageos.model.host.HostList) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

HostList (com.emc.storageos.model.host.HostList)11 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 Path (javax.ws.rs.Path)6 URI (java.net.URI)3 MapCluster (com.emc.storageos.api.mapper.functions.MapCluster)2 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)2 Cluster (com.emc.storageos.db.client.model.Cluster)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 MapVcenter (com.emc.storageos.api.mapper.functions.MapVcenter)1 MapVcenterDataCenter (com.emc.storageos.api.mapper.functions.MapVcenterDataCenter)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)1 Host (com.emc.storageos.db.client.model.Host)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 TaskList (com.emc.storageos.model.TaskList)1