use of com.emc.storageos.model.compute.ComputeElementRestRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method listComputePoolElements.
public static void listComputePoolElements(String id) {
List<ComputeVirtualElementInfo> results = Lists.newArrayList();
List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
List<RelatedResourceRep> matchedElements = computePool.getMatchedComputeElements();
for (RelatedResourceRep poolElement : matchedElements) {
for (ComputeElementRestRep element : allComputeElements) {
if (element.getId().equals(poolElement.getId())) {
results.add(new ComputeVirtualElementInfo(element, computePool.getName(), (String) "No Name yet"));
break;
}
}
}
renderJSON(DataTablesSupport.createJSON(results, params));
}
use of com.emc.storageos.model.compute.ComputeElementRestRep 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.ComputeElementRestRep 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;
}
use of com.emc.storageos.model.compute.ComputeElementRestRep in project coprhd-controller by CoprHD.
the class ComputeMapper method map.
public static ComputeElementRestRep map(ComputeElement from, Host host, Cluster cluster) {
if (from == null) {
return null;
}
ComputeElementRestRep to = new ComputeElementRestRep();
mapDiscoveredSystemObjectFields(from, to);
to.setRam(from.getRam());
to.setNumOfCores(from.getNumOfCores());
to.setNumOfProcessors(from.getNumberOfProcessors());
to.setNumOfThreads(from.getNumberOfThreads());
to.setProcessorSpeed(from.getProcessorSpeed());
to.setUuid(from.getUuid());
to.setOriginalUuid(from.getOriginalUuid());
to.setAvailable(from.getAvailable());
to.setModel(from.getModel());
to.setComputeSystem(toRelatedResource(ResourceTypeEnum.COMPUTE_SYSTEM, from.getComputeSystem()));
to.setRegistrationStatus(from.getRegistrationStatus());
if (host != null) {
StringBuffer hostName = new StringBuffer();
if (cluster != null) {
hostName.append(cluster.getLabel() + ": ");
}
hostName.append(host.getLabel());
to.setHostName(hostName.toString());
}
return to;
}
Aggregations