diff --git a/src/sunstone/etc/sunstone-views/kvm/admin.yaml b/src/sunstone/etc/sunstone-views/kvm/admin.yaml index 097337b095..65c044322c 100644 --- a/src/sunstone/etc/sunstone-views/kvm/admin.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/admin.yaml @@ -259,6 +259,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -272,6 +273,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -530,6 +532,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml index 1ac30296cb..d703f048de 100644 --- a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml @@ -258,6 +258,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -271,6 +272,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -531,6 +533,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/kvm/user.yaml b/src/sunstone/etc/sunstone-views/kvm/user.yaml index 37c2cc14c1..76d0dd3936 100644 --- a/src/sunstone/etc/sunstone-views/kvm/user.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/user.yaml @@ -251,6 +251,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -264,6 +265,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -524,6 +526,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/mixed/admin.yaml b/src/sunstone/etc/sunstone-views/mixed/admin.yaml index 2f92946bb2..cb273a041a 100644 --- a/src/sunstone/etc/sunstone-views/mixed/admin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/admin.yaml @@ -259,6 +259,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -272,6 +273,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -532,6 +534,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml index 1ac30296cb..d703f048de 100644 --- a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml @@ -258,6 +258,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -271,6 +272,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -531,6 +533,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/mixed/user.yaml b/src/sunstone/etc/sunstone-views/mixed/user.yaml index 37c2cc14c1..76d0dd3936 100644 --- a/src/sunstone/etc/sunstone-views/mixed/user.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/user.yaml @@ -251,6 +251,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -264,6 +265,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -524,6 +526,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml index db6c5dd035..39367f2e8c 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml @@ -257,6 +257,7 @@ tabs: Template.unlock: false Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -270,6 +271,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -530,6 +532,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml index ca398d3f27..67cd202f92 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml @@ -258,6 +258,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -271,6 +272,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -531,6 +533,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/vcenter/user.yaml b/src/sunstone/etc/sunstone-views/vcenter/user.yaml index 37c2cc14c1..76d0dd3936 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/user.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/user.yaml @@ -251,6 +251,7 @@ tabs: Template.unlock: true Template.edit_labels: true Template.menu_labels: true + Template.numa: true template_creation_tabs: general: true storage: true @@ -264,6 +265,7 @@ tabs: hybrid: true vmgroup: true other: true + numa: true oneflow-templates-tab: panel_tabs: service_template_info_tab: true @@ -524,6 +526,7 @@ tabs: host_zombies_tab: true host_esx_tab: true host_pci_tab: true + host_numa_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/public/app/opennebula/action.js b/src/sunstone/public/app/opennebula/action.js index 64d4dd0799..080436bad8 100644 --- a/src/sunstone/public/app/opennebula/action.js +++ b/src/sunstone/public/app/opennebula/action.js @@ -434,7 +434,9 @@ define(function(require) { return ""+id; }, - + "get_all_cache": function() { + return listCache; + }, "clear_cache": _clearCache }; diff --git a/src/sunstone/public/app/tabs/hosts-tab.js b/src/sunstone/public/app/tabs/hosts-tab.js index f552eddc4e..3bcffce70b 100644 --- a/src/sunstone/public/app/tabs/hosts-tab.js +++ b/src/sunstone/public/app/tabs/hosts-tab.js @@ -35,7 +35,8 @@ define(function(require) { require('./hosts-tab/panels/wilds'), require('./hosts-tab/panels/zombies'), require('./hosts-tab/panels/esx'), - require('./hosts-tab/panels/pci') + require('./hosts-tab/panels/pci'), + require('./hosts-tab/panels/numa') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js b/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js new file mode 100644 index 0000000000..e7ace6ee4c --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js @@ -0,0 +1,217 @@ +/* -------------------------------------------------------------------------- */ +/* 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 ProgressBar = require('utils/progress-bar'); + var Humanize = require('utils/humanize'); + var Sunstone = require('sunstone'); + var TemplateUtils = require('utils/template-utils'); + + /* + TEMPLATES + */ + + var TemplateNUMA = require('hbs!./numa/html'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./numa/panelId'); + var RESOURCE = "Host"; + var SELECT_ID = "numa-pinned-host"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Numa"); + this.icon = "fa-chart-pie"; + this.element = info[RESOURCE.toUpperCase()]; + return this; + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + Panel.prototype.onShow = _onShow; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateNUMA(); + } + + function _onShow(context){ + var that = this; + $("#"+SELECT_ID).change(function(e){ + if(that.element && that.element.ID && that.element.TEMPLATE){ + var template = $.extend({}, that.element.TEMPLATE); + template.PIN_POLICY = $(this).val(); + template_str = TemplateUtils.templateToString(template); + Sunstone.runAction(RESOURCE + ".update_template", that.element.ID, template_str); + } + }); + } + + function capitalize(string){ + return typeof string !== 'string'? "" : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } + + function _setup(context) { + var that = this; + if (that && that.element && that.element.HOST_SHARE && that.element.HOST_SHARE.NUMA_NODES) { + var numaNodes = that.element.HOST_SHARE.NUMA_NODES.NODE; + if (!(numaNodes instanceof Array)) { + numaNodes = [numaNodes]; + } + var options = [{'value':'NONE'},{'value':'PINNED'}]; + var select = $(" + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + 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("
"+prop.toLocaleLowerCase()+":
"+element.TEMPLATE.TOPOLOGY[prop]); + } + description.append("("+descriptionText.join(" ").trim()+")"); + } + info.map(function(core, index){ + if(displaySubtitle){ + subtitle.text("Cores & CPUS"); + displaySubtitle = false; + } + + var placeBody = tBody.find("tr:last"); + if(count === 0){ + placeBody = tBody.append($("
")).find("tr:last"); + } + placeBody.append( + $("
",{"colspan":2,"class":"text-center"}).append( + $("
").text("Node "+index) + ) + ); + if(core.CPUS){ + var cpus = core.CPUS.split(","); + if(cpus instanceof Array){ + cpus.map(function(cpu){ + if(core.MEMORY){ + var infoMemory = core.MEMORY; + var total = infoMemory ? parseInt(infoMemory): 0; + var used = infoMemory ? parseInt(infoMemory) : 0; + var parser = Humanize.sizeFromKB; + if (total > 0) { + var ratio = Math.round((used / total) * 100); + info_str = parser(used) + ' / ' + parser(total) + ' (' + ratio + '%)'; + } else { + if (info.TYPE == 1) { + info_str = '- / -'; + } else { + info_str = Humanize.size(used) + ' / -'; + } + } + progress = ProgressBar.html(used, total, info_str, 'memory-used'); + } + + placeBody.find("td:last").append( + $("
",{"class":"small-6 columns cpu busy"}).append( + $("
",{"class":""}).text("CPU #"+cpu) + ) + ); + + }); + } + placeBody.find("td:last").append($("
",{'class':'small-12 columns'}).css({"padding": "0px", + "margin-top": "2rem"}).append($("
",{'class':'text-left'}).text("Memory").css({'padding-bottom':'0px'}).add(progress))); + } + count = count >= limit ? 0 : count+1; + }); + coreTable.append(tBody); + $("#numaPlaceVM").empty().append(subtitle.append(description).add(coreTable)); + } } }); diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/capacity/html.hbs b/src/sunstone/public/app/tabs/vms-tab/panels/capacity/html.hbs index 4ce5708dea..5d42b02b06 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/capacity/html.hbs +++ b/src/sunstone/public/app/tabs/vms-tab/panels/capacity/html.hbs @@ -90,3 +90,5 @@
+
+
diff --git a/src/sunstone/public/app/utils/progress-bar.js b/src/sunstone/public/app/utils/progress-bar.js index 96b19d6776..0372dfc8b8 100644 --- a/src/sunstone/public/app/utils/progress-bar.js +++ b/src/sunstone/public/app/utils/progress-bar.js @@ -15,7 +15,7 @@ /* -------------------------------------------------------------------------- */ define(function(require) { - var _quotaBarHtml = function(usage, limit, info_str) { + var _quotaBarHtml = function(usage, limit, info_str, className="" ) { info_str = info_str || (usage + ' / ' + ((limit >= 0) ? limit : '-')); var value = "0"; @@ -26,11 +26,14 @@ define(function(require) { max = limit; } - html = '' + info_str + '' + - '
' + - ''; - - return html; + html = $("",{'class':'progress-text right', 'style':'font-size: 12px'}).text( + info_str + ).add( + $("
") + ).add( + $("",{'class':className, 'value':value,'max':limit}) + ); + return $("
").append(html).html(); } return { diff --git a/src/sunstone/public/scss/_layout.scss b/src/sunstone/public/scss/_layout.scss index 919e6ae78a..6790c45887 100644 --- a/src/sunstone/public/scss/_layout.scss +++ b/src/sunstone/public/scss/_layout.scss @@ -134,4 +134,29 @@ overflow-y: auto; max-height: 6em; +} + +#numa-topology-display{ + margin-bottom: 2rem; +} + +progress{ + &.memory-used{ + height: 1rem; + color: $busy; + margin-bottom: 2rem; + background-color: $free; + &::-webkit-progress-value{ + background-color: $busy; + } + &::-webkit-progress-bar{ + background-color: $free; + } + &::-moz-progress-bar{ + background-color: $busy; + } + &::-ms-fill{ + background-color: $busy; + } + } } \ No newline at end of file diff --git a/src/sunstone/public/scss/_settings.scss b/src/sunstone/public/scss/_settings.scss index 4586a5bd56..5520385094 100644 --- a/src/sunstone/public/scss/_settings.scss +++ b/src/sunstone/public/scss/_settings.scss @@ -66,6 +66,8 @@ $black: #0a0a0a; $dark-black: #000; //$black: #333; $white: #fefefe; +$free: #cacaca; +$busy: #4DBBD3; $deploying-color: #C7731F; $error-color: #cf280e; $powering_off-color: #cf280e; diff --git a/src/sunstone/public/scss/_table.scss b/src/sunstone/public/scss/_table.scss index 1f38a15cc4..91a6ec0d96 100644 --- a/src/sunstone/public/scss/_table.scss +++ b/src/sunstone/public/scss/_table.scss @@ -32,6 +32,34 @@ table { border-bottom: 1px solid smart-scale($table-background, $table-hover-scale); border-left: 0; border-right: 0; + td{ + .cpu{ + margin: 0px; + padding: 0px; + a,.no-vm{ + color: $white; + font-weight: bold; + padding: 5px; + display: inline-block; + width: 100%; + box-sizing: border-box; + } + } + + .busy{ + background-color: $busy; + color: $white; + font-weight: bold; + border: 1px solid $white; + } + + .free{ + background-color: $free; + font-weight: bold; + color: $white; + border: 1px solid $white; + } + } } tfoot {