Search in sources :

Example 1 with ComputeVirtualElementInfo

use of models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo in project coprhd-controller by CoprHD.

the class ComputeVirtualPools method listComputeElementsJson.

public static void listComputeElementsJson(String cvpid, ComputeVirtualPoolsForm computeVirtualPool) {
    List<ComputeVirtualElementInfo> results = Lists.newArrayList();
    computeVirtualPool.validateQualifiers("computeVirtualPool");
    if (Validation.hasErrors()) {
        // cannot call the errorhandler from inside the json call
        Logger.info("has errors error: %s", Validation.errors().toString());
    } else {
        List<ComputeSystemRestRep> allComputes = ComputeSystemUtils.getComputeSystems();
        List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
        if (NullColumnValueGetter.isNotNullValue(cvpid)) {
            computeVirtualPool.id = NullColumnValueGetter.getStringValue(cvpid);
            // We always show the full list of matching elements - in case of manual - selected ones will be checked
            List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
            for (ComputeElementRestRep element : allComputeElements) {
                String computeSystemName = ": " + element.getName();
                for (ComputeSystemRestRep compSys : allComputes) {
                    if (compSys.getId().equals(element.getComputeSystem().getId())) {
                        computeSystemName = compSys.getName() + computeSystemName;
                        break;
                    }
                }
                for (ComputeElementRestRep filteredElement : matchedElements) {
                    if (filteredElement.getId().equals(element.getId())) {
                        results.add(new ComputeVirtualElementInfo(element, element.getName(), computeSystemName));
                        break;
                    }
                }
            }
        } else {
            List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
            for (ComputeElementRestRep elementA : allComputeElements) {
                String computeSystemName = ": " + elementA.getName();
                for (ComputeSystemRestRep compSys : allComputes) {
                    if (compSys.getId().equals(elementA.getComputeSystem().getId())) {
                        computeSystemName = compSys.getName() + computeSystemName;
                        break;
                    }
                }
                for (ComputeElementRestRep elementM : matchedElements) {
                    if (elementM.getId().toString().equals(elementA.getId().toString())) {
                        results.add(new ComputeVirtualElementInfo(elementA, elementA.getName(), computeSystemName));
                    }
                }
            }
        }
    }
    renderJSON(DataTablesSupport.createJSON(results, params));
}
Also used : ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) List(java.util.List) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) ComputeVirtualElementInfo(models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)

Example 2 with ComputeVirtualElementInfo

use of models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo 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)

Aggregations

ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ComputeVirtualElementInfo (models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)1 ComputeVirtualPoolRestRep (com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)1