Search in sources :

Example 1 with ComputeSystemRestRep

use of com.emc.storageos.model.compute.ComputeSystemRestRep in project coprhd-controller by CoprHD.

the class VirtualArrayService method mapValidServiceProfileTemplatesToComputeSystem.

private ComputeSystemBulkRep mapValidServiceProfileTemplatesToComputeSystem(ComputeSystemBulkRep bulkRep, URI varrayId) {
    _log.debug("mapping Service Profile Templates valid for varray to the Compute Systems");
    ComputeSystemBulkRep rep = new ComputeSystemBulkRep();
    List<ComputeSystemRestRep> computeSystemList = new ArrayList<ComputeSystemRestRep>();
    for (ComputeSystemRestRep computeSystem : bulkRep.getComputeSystems()) {
        computeSystem.setServiceProfileTemplates(getServiceProfileTemplatesForComputeSystem(computeSystem.getId(), varrayId));
        computeSystemList.add(computeSystem);
    }
    rep.setComputeSystems(computeSystemList);
    return rep;
}
Also used : ArrayList(java.util.ArrayList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 2 with ComputeSystemRestRep

use of com.emc.storageos.model.compute.ComputeSystemRestRep in project coprhd-controller by CoprHD.

the class ComputeMapper method map.

public static ComputeSystemRestRep map(ComputeSystem from) {
    if (from == null) {
        return null;
    }
    ComputeSystemRestRep to = new ComputeSystemRestRep();
    mapDiscoveredSystemObjectFields(from, to);
    to.setIpAddress(from.getIpAddress());
    to.setPortNumber(from.getPortNumber());
    to.setUseSSL(from.getSecure());
    to.setUsername(from.getUsername());
    to.setVersion(from.getVersion());
    to.setOsInstallNetwork(from.getOsInstallNetwork());
    if (from.getComputeImageServer() != null) {
        to.setComputeImageServer(from.getComputeImageServer().toString());
    } else {
        to.setComputeImageServer("");
    }
    // sort vlans as numbers
    List<Integer> vlanIds = new ArrayList<Integer>();
    if (from.getVlans() != null) {
        for (String vlan : from.getVlans()) {
            try {
                vlanIds.add(Integer.parseInt(vlan));
            } catch (NumberFormatException e) {
            // skip
            }
        }
    }
    Collections.sort(vlanIds);
    StringBuilder vlanStr = null;
    for (int vlanId : vlanIds) {
        if (vlanStr == null) {
            vlanStr = new StringBuilder();
        } else {
            vlanStr.append(",");
        }
        vlanStr.append(vlanId);
    }
    if (vlanStr != null) {
        // cannot set null
        to.setVlans(vlanStr.toString());
    }
    return to;
}
Also used : ArrayList(java.util.ArrayList) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 3 with ComputeSystemRestRep

use of com.emc.storageos.model.compute.ComputeSystemRestRep in project coprhd-controller by CoprHD.

the class ComputeSystems method elements.

public static void elements(String id) {
    addReferenceData();
    ComputeSystemRestRep computeSystem = ComputeSystemUtils.getComputeSystem(id);
    ComputeSystemElementDataTable dataTable = new ComputeSystemElementDataTable();
    render("@listElements", computeSystem, dataTable);
}
Also used : ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) ComputeSystemElementDataTable(models.datatable.ComputeSystemElementDataTable)

Example 4 with ComputeSystemRestRep

use of com.emc.storageos.model.compute.ComputeSystemRestRep in project coprhd-controller by CoprHD.

the class ComputeVirtualPools method getServiceProfileTemplates.

public static void getServiceProfileTemplates(ComputeVirtualPoolsForm computeVirtualPool) {
    List<ComputeSystemRestRep> allComputes = Lists.newArrayList();
    List<StringOption> templateList = Lists.newArrayList();
    List<String> temps = Lists.newArrayList();
    if (computeVirtualPool.id != null) {
        ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(computeVirtualPool.id);
        for (NamedRelatedResourceRep tmp : computePool.getServiceProfileTemplates()) {
            temps.add(tmp.getId().toString());
        }
    }
    Map<String, Set<String>> csTemplatesMap = new HashMap<String, Set<String>>();
    Map<String, String> computeSystemsMap = new HashMap<String, String>();
    Map<String, String> templatesMap = new HashMap<String, String>();
    if (computeVirtualPool.virtualArrays != null) {
        for (String arrayId : computeVirtualPool.virtualArrays) {
            List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(uri(arrayId));
            for (ComputeSystemRestRep acomp : arrayComputes) {
                String compId = acomp.getId().toString();
                if (!computeSystemsMap.containsKey(compId)) {
                    computeSystemsMap.put(compId, acomp.getName());
                }
                Set<String> spts = csTemplatesMap.get(compId);
                if (spts == null) {
                    spts = new HashSet<String>();
                }
                for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
                    spts.add(spt.getId().toString());
                    if (!templatesMap.containsKey(spt.getId().toString())) {
                        templatesMap.put(spt.getId().toString(), spt.getName());
                    }
                }
                csTemplatesMap.put(compId, spts);
            }
        }
        for (Entry<String, Set<String>> comp : csTemplatesMap.entrySet()) {
            Set<String> compTemplates = comp.getValue();
            if (compTemplates != null && !compTemplates.isEmpty()) {
                String systemName = ComputeSystemTypes.getDisplayValue(ComputeSystemTypes.UCS) + " " + computeSystemsMap.get(comp.getKey());
                computeVirtualPool.systems.add(new StringOption(comp.getKey(), systemName));
                List<StringOption> templateOptions = Lists.newArrayList();
                templateOptions.add(new StringOption("NONE", ""));
                for (String template : compTemplates) {
                    templateOptions.add(new StringOption(template, templatesMap.get(template)));
                    if (!temps.isEmpty()) {
                        for (String templateId : temps) {
                            if (templateId.contains(template)) {
                                templateList.add(new StringOption(comp.getKey(), template));
                            }
                        }
                    }
                }
                computeVirtualPool.systemOptions.put(comp.getKey(), templateOptions);
            }
        }
        computeVirtualPool.selectedTemplates = "{}";
        if (!templateList.isEmpty()) {
            String jsonString = "{\"";
            for (int index = 0; index < templateList.size(); index++) {
                if (jsonString.indexOf("urn") > 0) {
                    jsonString = jsonString + ",\"";
                }
                jsonString = jsonString + templateList.get(index).id + "\":\"" + templateList.get(index).name + "\"";
            }
            jsonString = jsonString + "}";
            computeVirtualPool.selectedTemplates = jsonString;
        }
    } else {
        computeVirtualPool.selectedTemplates = "{}";
    }
    render("@templates", computeVirtualPool);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) StringOption(util.StringOption) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 5 with ComputeSystemRestRep

use of com.emc.storageos.model.compute.ComputeSystemRestRep 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)

Aggregations

ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)12 ArrayList (java.util.ArrayList)6 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)3 ComputeSystemBulkRep (com.emc.storageos.model.compute.ComputeSystemBulkRep)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)2 ComputeVirtualPoolRestRep (com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ComputeSystemElementDataTable (models.datatable.ComputeSystemElementDataTable)2 StringOption (util.StringOption)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 TaskList (com.emc.storageos.model.TaskList)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1