Search in sources :

Example 1 with ClusterList

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

the class TenantsService method listClusters.

/**
 * Lists the id and name for all the clusters that belong to the
 * tenant organization.
 *
 * @param id the URN of a ViPR tenant organization
 * @prereq none
 * @brief List tenant clusters
 * @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}/clusters")
public ClusterList listClusters(@PathParam("id") URI id) throws DatabaseException {
    // this called just for validation
    getTenantById(id, false);
    // check the user permissions for this tenant org
    verifyAuthorizedInTenantOrg(id, getUserFromContext());
    // get the children
    ClusterList list = new ClusterList();
    list.setClusters(map(ResourceTypeEnum.CLUSTER, listChildren(id, Cluster.class, "label", "tenant")));
    return list;
}
Also used : ClusterList(com.emc.storageos.model.host.cluster.ClusterList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ClusterList

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

the class ApiTestVcenter method getVcenterClusters.

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

Example 3 with ClusterList

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

the class ApiTestVcenter method getClustersByTenantApi.

private ClusterList getClustersByTenantApi(BalancedWebResource user, URI tenantId, int expectedStatus) {
    ClientResponse clientResponse = user.path(getClusterTenantApi(tenantId)).get(ClientResponse.class);
    Assert.assertEquals(expectedStatus, clientResponse.getStatus());
    if (expectedStatus != HttpStatus.SC_OK) {
        return null;
    }
    ClusterList clusterList = clientResponse.getEntity(ClusterList.class);
    Assert.assertNotNull(clusterList);
    return clusterList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ClusterList(com.emc.storageos.model.host.cluster.ClusterList)

Example 4 with ClusterList

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

the class VcenterDataCenterService method getVcenterDataCenterClusters.

/**
 * List the clusters in a vCenter data center.
 *
 * @param id the URN of a ViPR vCenter data center
 * @prereq none
 * @brief List vCenter data center clusters
 * @return The list of clusters of the vCenter data center.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}/clusters")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ClusterList getVcenterDataCenterClusters(@PathParam("id") URI id) throws DatabaseException {
    VcenterDataCenter dataCenter = queryResource(id);
    // check the user permissions
    verifyAuthorizedInTenantOrg(dataCenter.getTenant(), getUserFromContext());
    ClusterList list = new ClusterList();
    list.setClusters(map(ResourceTypeEnum.CLUSTER, listChildren(id, Cluster.class, "label", "vcenterDataCenter")));
    return list;
}
Also used : ClusterList(com.emc.storageos.model.host.cluster.ClusterList) MapVcenterDataCenter(com.emc.storageos.api.mapper.functions.MapVcenterDataCenter) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ClusterList

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

the class VcenterService method getVcenterClusters.

/**
 * List the clusters in a vCenter
 *
 * @param id the URN of a ViPR vCenter
 * @prereq none
 * @brief List vCenter clusters
 * @return The list of clusters of the vCenter.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}/clusters")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ClusterList getVcenterClusters(@PathParam("id") URI id) throws DatabaseException {
    Vcenter vcenter = queryObject(Vcenter.class, id, false);
    ArgValidator.checkEntity(vcenter, id, isIdEmbeddedInURL(id));
    // check the user permissions for this tenant org
    verifyAuthorizedInTenantOrg(_permissionsHelper.convertToACLEntries(vcenter.getAcls()));
    URI tenantId = URI.create(getUserFromContext().getTenantId());
    List<NamedElementQueryResultList.NamedElement> vCentersDataCenters = filterTenantResourcesByTenant(tenantId, VcenterDataCenter.class, listChildren(id, VcenterDataCenter.class, DATAOBJECT_NAME_FIELD, "vcenter"));
    ClusterList list = new ClusterList();
    Iterator<NamedElementQueryResultList.NamedElement> dataCentersIterator = vCentersDataCenters.iterator();
    while (dataCentersIterator.hasNext()) {
        NamedElementQueryResultList.NamedElement dataCenterElement = dataCentersIterator.next();
        list.getClusters().addAll(map(ResourceTypeEnum.CLUSTER, listChildren(dataCenterElement.getId(), Cluster.class, DATAOBJECT_NAME_FIELD, "vcenterDataCenter")));
    }
    return list;
}
Also used : MapVcenter(com.emc.storageos.api.mapper.functions.MapVcenter) ClusterList(com.emc.storageos.model.host.cluster.ClusterList) URI(java.net.URI) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ClusterList (com.emc.storageos.model.host.cluster.ClusterList)6 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 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 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 Cluster (com.emc.storageos.db.client.model.Cluster)1 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)1 URI (java.net.URI)1