Search in sources :

Example 11 with ComputeElementRestRep

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));
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) List(java.util.List) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) ComputeVirtualElementInfo(models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)

Example 12 with ComputeElementRestRep

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;
}
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 13 with ComputeElementRestRep

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

Example 14 with ComputeElementRestRep

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;
}
Also used : ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep)

Aggregations

ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)14 ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)7 ArrayList (java.util.ArrayList)6 URI (java.net.URI)5 Host (com.emc.storageos.db.client.model.Host)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 Cluster (com.emc.storageos.db.client.model.Cluster)3 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)3 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)3 List (java.util.List)3 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 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ComputeVirtualElementInfo (models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1