Search in sources :

Example 1 with HostList

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

the class TenantsService method listHosts.

/**
 * Lists the id and name for all the hosts that belong to the given tenant organization.
 * <p>
 * This method is deprecated. Use /compute/hosts instead
 *
 * @param id the URN of a ViPR tenant organization
 * @prereq none
 * @deprecated use {@link HostService#listHosts()}
 * @brief List tenant 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 })
@Path("/{id}/hosts")
@Deprecated
public HostList listHosts(@PathParam("id") URI id) throws DatabaseException {
    // this call validates the tenant id
    getTenantById(id, false);
    // check the user permissions for this tenant org
    verifyAuthorizedInTenantOrg(id, getUserFromContext());
    // get all host children
    HostList list = new HostList();
    list.setHosts(map(ResourceTypeEnum.HOST, listChildren(id, Host.class, "label", "tenant")));
    return list;
}
Also used : HostList(com.emc.storageos.model.host.HostList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with HostList

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

the class ClusterService method getClusterVblockHosts.

/**
 * List the vblock hosts of a cluster.
 *
 * @param id the URN of a ViPR cluster
 * @brief List vblock hosts for a cluster
 * @return The list of vblock hosts in the cluster.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}/vblock-hosts")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList getClusterVblockHosts(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, true);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    HostList list = new HostList();
    list.setHosts(map(ResourceTypeEnum.HOST, getVblockHostsFromCluster(id)));
    return list;
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) HostList(com.emc.storageos.model.host.HostList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with HostList

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

the class ClusterService method getClusterHosts.

/**
 * List the hosts of a cluster.
 *
 * @param id the URN of a ViPR cluster
 * @prereq none
 * @brief List cluster hosts
 * @return The list of hosts of the cluster.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}/hosts")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList getClusterHosts(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, true);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    HostList list = new HostList();
    list.setHosts(map(ResourceTypeEnum.HOST, listChildren(id, Host.class, "label", "cluster")));
    return list;
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) HostList(com.emc.storageos.model.host.HostList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with HostList

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

the class ApiTestVcenter method getVcenterHosts.

private HostList getVcenterHosts(BalancedWebResource user, URI vCenterId, int expectedStatus) {
    ClientResponse clientResponse = user.path(getVcenterHostsApi(vCenterId)).get(ClientResponse.class);
    Assert.assertEquals(expectedStatus, clientResponse.getStatus());
    if (expectedStatus != HttpStatus.SC_OK) {
        return null;
    }
    HostList hostList = clientResponse.getEntity(HostList.class);
    Assert.assertNotNull(hostList);
    return hostList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostList(com.emc.storageos.model.host.HostList)

Example 5 with HostList

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

the class VolumeGroupService method getHosts.

/**
 * Get application hosts
 *
 * @param id Application Id
 * @brief List hosts for an application
 * @return HostList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/hosts")
public HostList getHosts(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
    HostList result = new HostList();
    List<Host> hosts = getVolumeGroupHosts(_dbClient, volumeGroup);
    for (Host host : hosts) {
        result.getHosts().add(toNamedRelatedResource(host));
    }
    return result;
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) HostList(com.emc.storageos.model.host.HostList) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) 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