use of com.emc.storageos.model.compute.ComputeElementListRestRep in project coprhd-controller by CoprHD.
the class ComputeSystemService method getComputeElements.
/**
* Fetches all the Compute Elements belonging to a Compute System in ViPR
*
* @param id
* the URN of a ViPR Compute System
* @brief Show compute elements
* @return A detailed representation of compute elements
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/compute-elements")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ComputeElementListRestRep getComputeElements(@PathParam("id") URI id) throws InternalException {
ComputeElementListRestRep result = new ComputeElementListRestRep();
ArgValidator.checkFieldUriType(id, ComputeSystem.class, "id");
ComputeSystem cs = queryResource(id);
URIQueryResultList ceUriList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), ceUriList);
Iterator<URI> iterator = ceUriList.iterator();
Collection<URI> hostIds = _dbClient.queryByType(Host.class, true);
Collection<Host> hosts = _dbClient.queryObjectFields(Host.class, Arrays.asList("label", "computeElement", "cluster"), ControllerUtils.getFullyImplementedCollection(hostIds));
while (iterator.hasNext()) {
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, iterator.next());
if (ce != null) {
Host associatedHost = null;
for (Host host : hosts) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getComputeElement().equals(ce.getId())) {
associatedHost = host;
break;
}
}
Cluster cluster = null;
if (associatedHost != null && !NullColumnValueGetter.isNullURI(associatedHost.getCluster())) {
cluster = _dbClient.queryObject(Cluster.class, associatedHost.getCluster());
}
ComputeElementRestRep rest = map(ce, associatedHost, cluster);
if (rest != null) {
result.getList().add(rest);
}
}
}
return result;
}
use of com.emc.storageos.model.compute.ComputeElementListRestRep in project coprhd-controller by CoprHD.
the class ComputeSystemService method getProvisionedBlades.
private List<String> getProvisionedBlades(ComputeSystem cs) {
List<String> provHostList = new ArrayList<String>();
ComputeElementListRestRep result = getComputeElements(cs.getId());
List<ComputeElementRestRep> blades = result.getList();
for (ComputeElementRestRep ce : blades) {
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getHostComputeElementConstraint(ce.getId()), uris);
List<Host> hosts = _dbClient.queryObject(Host.class, uris, true);
if (!hosts.isEmpty()) {
provHostList.add(hosts.get(0).getHostName());
}
}
return provHostList;
}
Aggregations