").text("USAGE"))
+ )
+ )
+ );
+ var body = $("");
+ infoHugepages.map(function(element,index){
+ body.append(
+ $("
").append(
+ $("
").text(
+ element["SIZE"]
+ ).add(
+ $("
").text(element["FREE"])
+ ).add(
+ $("
").text(element["PAGES"])
+ ).add(
+ $("
").text(element["USAGE"])
+ )
+ )
+ )
+ });
+ hugepage.append(hugepageTable.append(body));
+ }
+ }
+ $("#placeNumaInfo").append(title.add(subtitle).add(coreTable).add($("",{"class":"row"}).append(memory.add(hugepage))));
+ });
+ }
+ }
+})
+
diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/numa/html.hbs b/src/sunstone/public/app/tabs/hosts-tab/panels/numa/html.hbs
new file mode 100644
index 0000000000..edc035f1be
--- /dev/null
+++ b/src/sunstone/public/app/tabs/hosts-tab/panels/numa/html.hbs
@@ -0,0 +1,20 @@
+{{! -------------------------------------------------------------------------- }}
+{{! Copyright 2002-2019, OpenNebula Project, OpenNebula Systems }}
+{{! }}
+{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
+{{! not use this file except in compliance with the License. You may obtain }}
+{{! a copy of the License at }}
+{{! }}
+{{! http://www.apache.org/licenses/LICENSE-2.0 }}
+{{! }}
+{{! Unless required by applicable law or agreed to in writing, software }}
+{{! distributed under the License is distributed on an "AS IS" BASIS, }}
+{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
+{{! See the License for the specific language governing permissions and }}
+{{! limitations under the License. }}
+{{! -------------------------------------------------------------------------- }}
+
+
+
+
+
diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/numa/panelId.js b/src/sunstone/public/app/tabs/hosts-tab/panels/numa/panelId.js
new file mode 100644
index 0000000000..fd01ef5e8e
--- /dev/null
+++ b/src/sunstone/public/app/tabs/hosts-tab/panels/numa/panelId.js
@@ -0,0 +1,19 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
+/* not use this file except in compliance with the License. You may obtain */
+/* a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
+/* See the License for the specific language governing permissions and */
+/* limitations under the License. */
+/* -------------------------------------------------------------------------- */
+
+define(function(require) {
+ return 'host_numa_tab';
+})
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create-common.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create-common.js
index 9f99c5621f..202b0d9956 100644
--- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create-common.js
+++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create-common.js
@@ -49,7 +49,8 @@ define(function(require) {
require("./create/wizard-tabs/scheduling"),
require("./create/wizard-tabs/hybrid"),
require("./create/wizard-tabs/vmgroup"),
- require("./create/wizard-tabs/other")
+ require("./create/wizard-tabs/other"),
+ require("./create/wizard-tabs/numa")
];
var TEMPLATES_TAB_ID = require("tabs/templates-tab/tabId");
@@ -161,10 +162,32 @@ define(function(require) {
var templateJSON = {};
$.each(this.wizardTabs, function(index, wizardTab) {
$.extend(true, templateJSON, wizardTab.retrieve($("#" + wizardTab.wizardTabId, context)));
-
var a = templateJSON;
});
+
+ if(templateJSON["TOPOLOGY"] && templateJSON["TOPOLOGY"]["BORRAR"]){
+ delete templateJSON["TOPOLOGY"];
+ }
+
+ if(
+ templateJSON["TOPOLOGY"] &&
+ templateJSON["TOPOLOGY"]["HUGEPAGE_SIZE"] !== undefined &&
+ templateJSON["TOPOLOGY"]["HUGEPAGE_SIZE"] !== null &&
+ templateJSON["TOPOLOGY"]["HUGEPAGE_SIZE"].length<=0
+ ){
+ delete templateJSON["TOPOLOGY"]["HUGEPAGE_SIZE"];
+ }
+
+ if(
+ templateJSON["TOPOLOGY"] &&
+ templateJSON["TOPOLOGY"]["MEMORY_ACCESS"] !== undefined &&
+ templateJSON["TOPOLOGY"]["MEMORY_ACCESS"] !== null &&
+ templateJSON["TOPOLOGY"]["MEMORY_ACCESS"].length<=0
+ ){
+ delete templateJSON["TOPOLOGY"]["MEMORY_ACCESS"];
+ }
+
// vCenter PUBLIC_CLOUD is not defined in the hybrid tab. Because it is
// part of an array, and it is filled in different tabs, the $.extend deep
// merge can't work. We define an auxiliary attribute for it.
@@ -196,7 +219,6 @@ define(function(require) {
delete templateJSON["NIC_PCI"];
}
-
return templateJSON;
}
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa.js
new file mode 100644
index 0000000000..c3b0130742
--- /dev/null
+++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa.js
@@ -0,0 +1,227 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
+/* not use this file except in compliance with the License. You may obtain */
+/* a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
+/* See the License for the specific language governing permissions and */
+/* limitations under the License. */
+/* -------------------------------------------------------------------------- */
+
+define(function(require) {
+ /*
+ DEPENDENCIES
+ */
+
+ var Config = require("sunstone-config");
+ var Locale = require("utils/locale");
+ var Tips = require("utils/tips");
+ var WizardFields = require("utils/wizard-fields");
+ var FilesTable = require("tabs/files-tab/datatable");
+ var UniqueId = require("utils/unique-id");
+ var OpenNebulaAction = require('opennebula/action');
+
+ /*
+ TEMPLATES
+ */
+
+ var TemplateHTML = require("hbs!./numa/html");
+
+ /*
+ CONSTANTS
+ */
+
+ var WIZARD_TAB_ID = require("./numa/wizardTabId");
+ var RESOURCE = "HOST";
+ var BUTTON_NUMA_TOPOLOGY = "#numa-topology";
+ var HUGEPAGE_SELECTED_VALUE = "";
+ var idsElements = {
+ cores: "#numa-cores",
+ threads: "#numa-threads",
+ hugepages: "#numa-hugepages",
+ sockets: "#numa-sockets",
+ memory: "#numa-memory",
+ pin: "#numa-pin-policy"
+ }
+
+ var numaStatus = null;
+ /*
+ CONSTRUCTOR
+ */
+
+ function WizardTab(opts) {
+ if (!Config.isTemplateCreationTabEnabled(opts.tabId, "os_booting")) {
+ throw "Wizard Tab not enabled";
+ }
+ this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
+ this.icon = "fa-chart-pie";
+ this.title = Locale.tr("NUMA");
+ }
+
+ WizardTab.prototype.constructor = WizardTab;
+ WizardTab.prototype.html = _html;
+ WizardTab.prototype.setup = _setup;
+ WizardTab.prototype.onShow = _onShow;
+ WizardTab.prototype.retrieve = _retrieve;
+ WizardTab.prototype.fill = _fill;
+
+ return WizardTab;
+
+ /*
+ FUNCTION DEFINITIONS
+ */
+
+ function _html() {
+ var that = this;
+ return TemplateHTML();
+ }
+
+ function successCallback(request, opts, infohost){
+ //console.log("CACHE ", OpenNebulaAction.get_all_cache());
+ var selector = $(idsElements.hugepages);
+ selector.empty();
+ if(infohost && infohost.HOST_POOL && infohost.HOST_POOL.HOST){
+ var hosts = infohost.HOST_POOL.HOST;
+ var hugepages = [];
+ if (!(hosts instanceof Array)) {
+ hosts = [hosts];
+ }
+ hosts.map(function(host){
+ if(host && host.HOST_SHARE && host.NAME && host.HOST_SHARE.NUMA_NODES && host.HOST_SHARE.NUMA_NODES.NODE){
+ var name = host.NAME;
+ var numaNodes = host.HOST_SHARE.NUMA_NODES.NODE;
+ if (!(numaNodes instanceof Array)) {
+ numaNodes = [numaNodes];
+ }
+ numaNodes.map(function(node){
+ if(node && node.HUGEPAGE && node.NODE_ID){
+ node.HUGEPAGE.map(function(hugepage){
+ if(!hugepages.includes(hugepage.SIZE)){
+ hugepages.push(hugepage.SIZE);
+ }
+ });
+ }
+ });
+ }
+ });
+ selector.append($("",{"value":""}).text("-"));
+ hugepages.map(function(hugepage){
+ var selected = hugepage === HUGEPAGE_SELECTED_VALUE;
+ selector.append($("",{"value": hugepage}).text(hugepage).prop('selected', selected));
+ });
+ }
+ }
+
+ function getStatusNuma(){
+ return numaStatus;
+ }
+
+ function errorCallback(error, error1){
+ console.log("error->", error, error1);
+ }
+
+ function _onShow(context, panelForm) {
+ var that = this;
+ $(BUTTON_NUMA_TOPOLOGY, context).on( 'click', function() {
+ var form = $(".numa-form",context);
+ if( $(this).is(':checked') ){
+ form.removeClass("hide");
+ OpenNebulaAction.clear_cache(RESOURCE);
+ OpenNebulaAction.list(
+ {
+ data: {pool_filter: -2},
+ success: successCallback,
+ error: errorCallback
+ },
+ RESOURCE
+ );
+ numaStatus = true;
+ }else{
+ form.addClass("hide");
+ numaStatus = false;
+ }
+ });
+ }
+
+ function _setup(context) {
+ var that = this;
+ Foundation.reflow(context, "tabs");
+ }
+
+ function _retrieve(context) {
+ var templateJSON = { TOPOLOGY : {BORRAR:"BORRAR"} };
+ if(getStatusNuma()){
+ delete templateJSON["TOPOLOGY"]["BORRAR"];
+
+ var temp = {};
+ var policy = _getValue(idsElements.pin, context);
+ if(policy && policy.length){
+ temp.PIN_POLICY = policy;
+ }
+ var sockets = _getValue(idsElements.sockets, context);
+ if(sockets && sockets.length){
+ temp.SOCKETS = sockets;
+ }
+ var cores = _getValue(idsElements.cores, context);
+ if(cores && cores.length){
+ temp.CORES = cores;
+ }
+ var threads = _getValue(idsElements.threads, context);
+ if(threads && threads.length){
+ temp.THREADS = threads;
+ }
+ temp.HUGEPAGE_SIZE = _getValue(idsElements.hugepages, context);
+
+ temp.MEMORY_ACCESS = _getValue(idsElements.memory, context);
+
+ templateJSON.TOPOLOGY = temp;
+ }
+ return templateJSON;
+ }
+
+ function _getValue(id="", context=null){
+ rtn = null;
+ if(id.length && context){
+ rtn = $(String(id), context).val();
+ }
+ return rtn;
+ }
+
+ function _fillBootValue(id="", context=null, value="") {
+ if(id.length && context && value.length){
+ $(String(id), context).val(value);
+ }
+ }
+
+ function _fill(context, templateJSON) {
+ if(templateJSON && templateJSON.TOPOLOGY){
+ var topology = templateJSON.TOPOLOGY;
+ $(BUTTON_NUMA_TOPOLOGY).click();
+ if(topology && topology.CORES){
+ _fillBootValue(idsElements.cores, context, topology.CORES);
+ }
+ HUGEPAGE_SELECTED_VALUE = "";
+ if(topology && topology.HUGEPAGE_SIZE){
+ HUGEPAGE_SELECTED_VALUE = topology.HUGEPAGE_SIZE;
+ }
+ if(topology && topology.MEMORY_ACCESS){
+ _fillBootValue(idsElements.memory, context, topology.MEMORY_ACCESS);
+ }
+ if(topology && topology.PIN_POLICY){
+ _fillBootValue(idsElements.pin, context, topology.PIN_POLICY);
+ }
+ if(topology && topology.SOCKETS){
+ _fillBootValue(idsElements.sockets, context, topology.SOCKETS);
+ }
+ if(topology && topology.THREADS){
+ _fillBootValue(idsElements.threads, context, topology.THREADS);
+ }
+ }
+ }
+});
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/html.hbs
new file mode 100644
index 0000000000..d5a9e53b70
--- /dev/null
+++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/html.hbs
@@ -0,0 +1,73 @@
+{{! -------------------------------------------------------------------------- }}
+{{! Copyright 2002-2019, OpenNebula Project, OpenNebula Systems }}
+{{! }}
+{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
+{{! not use this file except in compliance with the License. You may obtain }}
+{{! a copy of the License at }}
+{{! }}
+{{! http://www.apache.org/licenses/LICENSE-2.0 }}
+{{! }}
+{{! Unless required by applicable law or agreed to in writing, software }}
+{{! distributed under the License is distributed on an "AS IS" BASIS, }}
+{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
+{{! See the License for the specific language governing permissions and }}
+{{! limitations under the License. }}
+{{! -------------------------------------------------------------------------- }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/wizardTabId.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/wizardTabId.js
new file mode 100644
index 0000000000..411f8c5309
--- /dev/null
+++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/numa/wizardTabId.js
@@ -0,0 +1,19 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
+/* not use this file except in compliance with the License. You may obtain */
+/* a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
+/* See the License for the specific language governing permissions and */
+/* limitations under the License. */
+/* -------------------------------------------------------------------------- */
+
+define(function(require){
+ return 'numaTab';
+});
diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/capacity.js b/src/sunstone/public/app/tabs/vms-tab/panels/capacity.js
index a04bf2e74a..1b6246e174 100644
--- a/src/sunstone/public/app/tabs/vms-tab/panels/capacity.js
+++ b/src/sunstone/public/app/tabs/vms-tab/panels/capacity.js
@@ -26,7 +26,9 @@ define(function(require) {
var Notifier = require('utils/notifier');
var Graphs = require('utils/graphs');
var StateActions = require('tabs/vms-tab/utils/state-actions');
-
+ var OpenNebulaAction = require('opennebula/action');
+ var Humanize = require('utils/humanize');
+ var ProgressBar = require('utils/progress-bar');
/*
TEMPLATES
*/
@@ -149,5 +151,88 @@ define(function(require) {
},
error: Notifier.onError
});
+
+ //NUMA DATA
+ var element = this.element;
+ var displaySubtitle = true;
+ var coreTable = $("
");
+ if(element && element.TEMPLATE && element.TEMPLATE.NUMA_NODE){
+ var info = element.TEMPLATE.NUMA_NODE;
+ if (!(info instanceof Array)) {
+ info = [info];
+ }
+ var limit = 3; //start in 0 is index of array
+ var count = 0;
+ var subtitle = $("");
+ var description = $("").css({'margin-left':'1rem','font-size': '0.9rem'});
+ var descriptionText = [];
+ var space = false;
+ var tBody = $("");
+ var progress = "";
+ //description info
+ if(element.TEMPLATE && element.TEMPLATE.TOPOLOGY ){
+ for (var prop in element.TEMPLATE.TOPOLOGY){
+ var styles = 'display: inline-block;font-weight: bold;color: #5f5d5d;';
+ if(space){
+ styles += 'margin-left: 0.3rem;';
+ }
+ space = true;
+ descriptionText.push("