Search in sources :

Example 6 with ComputeElementListRestRep

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;
}
Also used : ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with ComputeElementListRestRep

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;
}
Also used : ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)7 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)7 URI (java.net.URI)5 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 Host (com.emc.storageos.db.client.model.Host)3 Cluster (com.emc.storageos.db.client.model.Cluster)2 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)2 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)2 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)2 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 ComputeSystemBulkRep (com.emc.storageos.model.compute.ComputeSystemBulkRep)2 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 ComputeVirtualPool (com.emc.storageos.db.client.model.ComputeVirtualPool)1