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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations