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