1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

F #4039: Numa topology changes for vCenter (#750)

Signed-off-by: Frederick Borges <fborges@opennebula.io>
This commit is contained in:
Frederick Borges 2021-02-03 16:58:26 +01:00 committed by GitHub
parent 2706e23f53
commit df47b58cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 194 additions and 170 deletions

View File

@ -30,6 +30,7 @@ define(function(require) {
var UsersTable = require("tabs/users-tab/datatable");
var GroupTable = require("tabs/groups-tab/datatable");
var OpenNebulaHost = require("opennebula/host");
var CoresPerSocket = require("tabs/templates-tab/form-panels/create/wizard-tabs/utils/cores-per-socket");
/*
TEMPLATES
@ -42,6 +43,7 @@ define(function(require) {
*/
var WIZARD_TAB_ID = require('./general/wizardTabId');
var VCPU_SELECTOR = '#VCPU';
/*
CONSTRUCTOR
@ -244,17 +246,55 @@ define(function(require) {
$('.disabled_firecracker', formContext).prop("disabled", true);
$('.not_firecracker', formContext).hide();
$('.not_vcenter', formContext).show();
$('.only_vcenter', formContext).hide();
}
else if (this.value == "vcenter"){
// [GENERAL]
$(".cpu_input > input", formContext).val("");
// [NUMA]
$("#numa-pin-policy", formContext)
.prop("disabled", false)
.val("NONE")
.prop("disabled", true);
$("#numa-sockets", formContext)
.val("");
$("#numa-threads", formContext)
.prop("disabled", false)
.removeAttr("max")
.val("1")
.prop("disabled", true);
$('.disabled_firecracker', formContext).removeAttr("disabled");
$('.not_firecracker', formContext).show();
$('.not_vcenter', formContext).hide();
$('.only_vcenter', formContext).show();
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
}
else {
// [GENERAL]
$(".cpu_input > input", formContext).val("");
// [NUMA]
$("#numa-pin-policy", formContext).val("NONE");
$("#numa-pin-policy", formContext)
.prop("disabled", false)
.val("NONE");
$("#numa-sockets", formContext).val("");
$("#numa-threads", formContext).removeAttr("max").val("");
$("#numa-threads", formContext)
.prop("disabled", false)
.removeAttr("max")
.val("");
$('.disabled_firecracker', formContext).removeAttr("disabled");
$('.not_firecracker', formContext).show();
$('.not_vcenter', formContext).show();
$('.only_vcenter', formContext).hide();
}
});

View File

@ -24,6 +24,7 @@ define(function(require) {
var Tips = require("utils/tips");
var WizardFields = require("utils/wizard-fields");
var UserInputs = require("utils/user-inputs");
var CoresPerSocket = require("tabs/templates-tab/form-panels/create/wizard-tabs/utils/cores-per-socket");
/*
TEMPLATES
@ -31,6 +32,12 @@ define(function(require) {
var TemplateHTML = require("hbs!./capacity-create/html");
/*
CONSTANTS
*/
var VCPU_SELECTOR = '#VCPU';
/*
CONSTRUCTOR
*/
@ -145,32 +152,6 @@ define(function(require) {
_totalCost();
}
function _generateCores(context){
$('#CORES_PER_SOCKET').find('option').remove();
$("#CORES_PER_SOCKET", context).append($('<option>').val("").text(""));
var vcpu_count = parseInt($("#VCPU").val()) || 0;
for (var i = 1; i <= vcpu_count; i++){
if (vcpu_count%i === 0){
$('#CORES_PER_SOCKET').append($('<option>').val(i).text((i).toString()));
}
}
$('#CORES_PER_SOCKET option[value=""]').prop('selected', true);
}
function _calculateSockets(context){
var vcpu = $("#VCPU").val();
var cores_per_socket = $("#CORES_PER_SOCKET").val();
if ((vcpu != "") && (cores_per_socket != "")){
$("div.socket_info").show();
$("#number_sockets").text(vcpu/cores_per_socket);
}
else{
$("div.socket_info").hide();
}
}
function _setup(context) {
context.on("change", "#MEMORY", function() {
_calculatedRealMemory(context);
@ -189,12 +170,13 @@ define(function(require) {
});
context.on("change", "#VCPU", function(){
_generateCores(context);
_calculateSockets(context);
CoresPerSocket.generateCores(VCPU_SELECTOR);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
$('#selectedVCPU').val(this.value);
});
context.on("change", "#CORES_PER_SOCKET", function(){
_calculateSockets(context);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
});
// MB to GB
context.on("input", "div.memory_input input", function(){
@ -331,7 +313,7 @@ define(function(require) {
WizardFields.fill(context, element);
if(element.TOPOLOGY && element.TOPOLOGY.CORES) {
$('#CORES_PER_SOCKET').val(element.TOPOLOGY.CORES).change()
CoresPerSocket.selectOption(element.TOPOLOGY.CORES);
}
// Update memory_gb with the value set in memory

View File

@ -61,7 +61,7 @@
</div>
</div>
<div class="medium-2 small-12 columns">
<div class="row" id="memory_max_group">
<div class="row" id="memory_max_group" hidden>
<div class="small-12 columns">
<label class="">
{{tr "Max memory"}}
@ -210,7 +210,7 @@
</div>
</div>
<div class="medium-2 small-12 columns">
<div class="row" id="vcpu_max_group">
<div class="row" id="vcpu_max_group" hidden>
<div class="small-12 columns">
<label class="">
{{tr "Max VCPU"}}
@ -250,28 +250,4 @@
</div>
</div>
</div>
</div>
<div class="row">
<div class="medium-6 small-12 columns hypervisor only_vcenter" style="display: none;">
<div class="row">
<div class="small-12 columns">
<label class="" for="CORES_PER_SOCKET">
{{tr " Virtual Cores per Socket"}}
{{{tip (tr "Number of cores per socket. The number of sockets is automatically calculated dividing the VCPU value by the number of cores per socket value.")}}}
</label>
<div class="cores_per_socket_select">
<select wizard_field="CORES" id="CORES_PER_SOCKET"/>
</div>
</div>
</div>
</div>
<div class="medium-6 small-12 columns hypervisor only_vcenter socket_info" style="display: none;">
<div class="row">
<div class="small-12 columns">
<label>
{{tr "Sockets"}}: <span id="number_sockets"></span>
</label>
</div>
</div>
</div>
</div>

View File

@ -26,6 +26,7 @@ define(function(require) {
var UserInputs = require('utils/user-inputs');
var Config = require('sunstone-config');
var Notifier = require("utils/notifier");
var CoresPerSocket = require("tabs/templates-tab/form-panels/create/wizard-tabs/utils/cores-per-socket");
/*
TEMPLATES
@ -33,6 +34,12 @@ define(function(require) {
var TemplateHTML = require('hbs!./capacity-inputs/html');
/*
CONSTANTS
*/
var VCPU_SELECTOR = 'div.vcpu_input input, div.vcpu_input select';
/*
CONSTRUCTOR
*/
@ -62,34 +69,6 @@ define(function(require) {
Tips.setup(context);
}
function _calculateSockets(context){
var vcpu = $("div.vcpu_input input, div.vcpu_input select", context).val();
var cores_per_socket = $("#CORES_PER_SOCKET").val();
if ((vcpu != "") && (cores_per_socket != "")){
$("div.socket_info").show();
$("#number_sockets").text(parseInt(vcpu, 10)/parseInt(cores_per_socket, 10));
}
else{
$("div.socket_info").hide();
}
}
function _generateCores(context){
$("#CORES_PER_SOCKET", context).find('option').remove();
$("#CORES_PER_SOCKET", context).append($('<option>').val("").text(""));
var visor = $("div.vcpu_input input.visor")
var slider = $("div.vcpu_input input");
var select = $("div.vcpu_input select");
var from = visor.length? visor : slider.length ? slider : select;
var vcpuValue = from.val();
for (var i = 1; i <= vcpuValue; i++){
if (vcpuValue%i === 0){
$("#CORES_PER_SOCKET", context).append($('<option>').val(i).text((i).toString()));
}
}
}
/**
* Fills the capacity inputs
* @param {Object} context JQuery selector
@ -209,15 +188,12 @@ define(function(require) {
$(this).siblings("input").trigger("input");
});
if (element.TEMPLATE.HYPERVISOR == "vcenter"){
$("div.cores_per_socket_select_wrapper").show();
$("div.socket_info").show();
if (element.TEMPLATE.HYPERVISOR == "vcenter"){
var vcpuValue = $("div.vcpu_input input", context).val();
if (vcpuValue !== "") {
_generateCores(context);
if(element.TEMPLATE.TOPOLOGY) {
$('#CORES_PER_SOCKET').val(element.TEMPLATE.TOPOLOGY.CORES).change()
CoresPerSocket.generateCores(VCPU_SELECTOR);
if(element && element.TEMPLATE && element.TEMPLATE.TOPOLOGY && element.TEMPLATE.TOPOOGY.CORES) {
CoresPerSocket.selectOption(element.TEMPLATE.TOPOLOGY.CORES);
}
}
@ -228,33 +204,28 @@ define(function(require) {
max = element.attr("max");
if(parseInt(element.val(),10) >= parseInt(min,10) && parseInt(element.val(),10)<= parseInt(max,10)){
$("div.vcpu_input input", context).val(element.val());
_generateCores(context);
$('#CORES_PER_SOCKET option[value=""]').prop('selected', true);
_calculateSockets(context);
CoresPerSocket.generateCores(VCPU_SELECTOR);
CoresPerSocket.selectOption("");
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
} else{
element.val(max);
$("div.vcpu_input input", context).val(max).change();
Notifier.notifyError(Locale.tr("The value goes out of the allowed limits"));
}
} else{
_generateCores(context);
$('#CORES_PER_SOCKET option[value=""]').prop('selected', true);
_calculateSockets(context);
CoresPerSocket.generateCores(VCPU_SELECTOR);
CoresPerSocket.selectOption("");
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
}
});
$("#CORES_PER_SOCKET", context).on("change", function(){
_calculateSockets(context);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
})
_calculateSockets(context);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
}
else{
$("div.cores_per_socket_select_wrapper").hide();
$("div.socket_info").hide();
}
if (userInputs != undefined && userInputs.MEMORY != undefined){
attr = UserInputs.parse("MEMORY", userInputs.MEMORY);

View File

@ -48,22 +48,4 @@
<div class="vcpu_input">
</div>
</div>
<div class="cores_per_socket_select_wrapper small-12 columns end">
<label class="" for="CORES_PER_SOCKET">
{{tr "Virtual Cores per Socket"}}
{{{tip (tr "Number of cores per socket. The number of sockets is automatically calculated dividing the VCPU value by the number of cores per socket value")}}}
</label>
<div class="cores_per_socket_select">
<select wizard_field="CORES" id="CORES_PER_SOCKET"/>
</div>
</div>
<div class="small-12 columns socket_info">
<div class="row">
<div class="small-12 columns">
<label>
{{tr "Sockets"}}: <span id="number_sockets"></span>
</label>
</div>
</div>
</div>
</div>

View File

@ -61,6 +61,9 @@
<br></div>
</div>
</div>
<div class="row">
<div class="capacityCreate large-12 columns">{{{capacityCreateHTML}}}</div>
</div>
<fieldset class="hypervisor only_vcenter" style="display: none;">
<legend>{{tr "vCenter"}}</legend>
<div class="row hypervisor only_vcenter" style="display: none;">
@ -150,9 +153,6 @@
</div>
</div>
</fieldset>
<div class="row">
<div class="capacityCreate large-12 columns">{{{capacityCreateHTML}}}</div>
</div>
{{#isFeatureEnabled "showback"}}
<div class="row">
<div class="medium-12 columns">

View File

@ -26,6 +26,7 @@ define(function(require) {
var FilesTable = require("tabs/files-tab/datatable");
var UniqueId = require("utils/unique-id");
var OpenNebulaAction = require('opennebula/action');
var CoresPerSocket = require("tabs/templates-tab/form-panels/create/wizard-tabs/utils/cores-per-socket");
/*
TEMPLATES
@ -51,6 +52,7 @@ define(function(require) {
}
var numaStatus = null;
var VCPU_SELECTOR = '#VCPU';
/*
CONSTRUCTOR
*/
@ -168,6 +170,15 @@ define(function(require) {
function _setup(context) {
var that = this;
Foundation.reflow(context, "tabs");
$("#CORES_PER_SOCKET", context).on("change", function (){
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
$('#numa-cores').val(this.value);
});
$('#selectedVCPU',context).on('change', function (){
$('#VCPU').val(this.value).change();
});
}
function _retrieve(context) {

View File

@ -30,7 +30,7 @@
{{tr "Pin Policy"}}
{{{tip (tr "vCPU pinning preference: CORE, THREAD, SHARED, NONE")}}}
</label>
<select id="numa-pin-policy" class="disabled_firecracker">
<select id="numa-pin-policy">
<option value="NONE">{{tr "none"}}</option>
<option value="THREAD">{{tr "thread"}}</option>
<option value="SHARED">{{tr "shared"}}</option>
@ -49,7 +49,10 @@
{{tr "Cores"}}
{{{tip (tr "Number of cores per node")}}}
</label>
<input type="number" id="numa-cores">
<input type="number" id="numa-cores" class="not_vcenter">
<div class="only_vcenter" hidden>
<select id="CORES_PER_SOCKET"/>
</div>
</div>
<div class="small-6 columns">
<label for="numa-threads">
@ -58,14 +61,14 @@
</label>
<input type="number" id="numa-threads" min="1">
</div>
<div class="small-6 columns not_firecracker">
<div class="small-6 columns not_vcenter not_firecracker">
<label for="numa-hugepages">
{{tr "Hugepages Size"}}
{{{tip (tr "Size of the hugepages (MB). If not defined no hugepages will be used")}}}
</label>
<select id="numa-hugepages"></select>
</div>
<div class="small-6 columns not_firecracker">
<div class="small-6 columns not_vcenter not_firecracker">
<label for="numa-memory">
{{tr "Memory Access"}}
{{{tip (tr "Control if the memory is to be mapped shared or private")}}}
@ -76,6 +79,13 @@
<option value="private">{{tr "Private"}}</option>
</select>
</div>
<div class="small-6 columns">
<label for="selectedVCPU">
{{tr "Virtual CPU selected"}}
{{{tip (tr "Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")}}}
</label>
<input type="number" id="selectedVCPU">
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,82 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2021, 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) {
CORES_ID = '#CORES_PER_SOCKET';
/*
CONSTRUCTOR
*/
return {
"generateCores": _generateCores,
"calculateSockets": _calculateSockets,
"selectOption": _selectOption,
};
/*
FUNCTIONS
*/
function _generateCores(vcpu_selector){
$(CORES_ID).find('option').remove();
$(CORES_ID).append($('<option>').val("").text("-"));
var vcpu_count = parseInt($(vcpu_selector).val()) || 0;
for (var i = 1; i <= vcpu_count; i++){
if (vcpu_count%i === 0){
$(CORES_ID).append($('<option>').val(i).text((i).toString()));
}
}
$(CORES_ID + ' option[value=""]').prop('selected', true);
}
function _calculateSockets(vcpu_selector){
var vcpu = $(vcpu_selector).val();
var cores_per_socket = $(CORES_ID).val();
if ((vcpu != "") && (cores_per_socket != "")){
$("div.socket_info").show();
var number_sockets = vcpu/cores_per_socket;
$("#SOCKETS")
.prop("disabled", false)
.val(number_sockets)
.prop("disabled", true);
$("#numa-sockets")
.prop("disabled", false)
.val(number_sockets)
.prop("disabled", true);
}
else{
$("#SOCKETS")
.prop("disabled", false)
.val("")
.prop("disabled", true);
$("#numa-sockets")
.prop("disabled", false)
.val("")
.prop("disabled", true);
$("div.socket_info").hide();
}
}
function _selectOption(value){
$( CORES_ID + " option[value=\"" + value + "\"]")
.prop("selected", true)
.change();
}
});

View File

@ -29,6 +29,7 @@ define(function(require) {
var OpenNebulaAction = require("opennebula/action");
var Humanize = require("utils/humanize");
var ProgressBar = require("utils/progress-bar");
var CoresPerSocket = require("tabs/templates-tab/form-panels/create/wizard-tabs/utils/cores-per-socket")
/*
TEMPLATES
*/
@ -44,6 +45,7 @@ define(function(require) {
var RESIZE_DIALOG_ID = require("../dialogs/resize/dialogId");
var RESOURCE = "VM";
var XML_ROOT = "VM";
var VCPU_SELECTOR = 'div.vcpu_input input';
/*
CONSTRUCTOR
@ -92,32 +94,6 @@ define(function(require) {
});
}
function _calculateSockets(context){
var vcpu = $("div.vcpu_input input", context).val();
var cores_per_socket = $("#CORES_PER_SOCKET").val();
if ((vcpu != "") && (cores_per_socket != "")){
$("div.socket_info").show();
$("#number_sockets").text(vcpu/cores_per_socket);
}
else{
$("div.socket_info").hide();
}
}
function _generateCores(context){
$("#CORES_PER_SOCKET", context).find("option").remove();
$("#CORES_PER_SOCKET", context).append($("<option>").val("").text(""));
var vcpuValue = $("div.vcpu_input input").val();
for (var i = 1; i <= vcpuValue; i++){
if (vcpuValue%i === 0){
$("#CORES_PER_SOCKET", context).append($("<option>").val(i).text((i).toString()));
}
}
$("#CORES_PER_SOCKET option[value=\"\"]").prop("selected", true);
}
function _setup(context) {
var that = this;
@ -173,30 +149,24 @@ define(function(require) {
}
if (that.element.USER_TEMPLATE.HYPERVISOR == "vcenter"){
$("div.cores_per_socket_select_wrapper", dialogContext).attr("style", "");
$("div.socket_info", dialogContext).show();
var vcpuValue = $("div.vcpu_input input").val();
if (vcpuValue !== "" && that && that.element && that.element.TEMPLATE && that.element.TEMPLATE.TOPOLOGY && that.element.TEMPLATE.TOPOLOGY.CORES) {
_generateCores(dialogContext);
$("#CORES_PER_SOCKET option[value=\"" + that.element.TEMPLATE.TOPOLOGY.CORES + "\"]").prop("selected", true);
CoresPerSocket.generateCores(VCPU_SELECTOR);
CoresPerSocket.selectOption(that.element.TEMPLATE.TOPOLOGY.CORES);
}
$("div.vcpu_input input", dialogContext).on("change", function(){
_generateCores(dialogContext);
_calculateSockets(dialogContext);
CoresPerSocket.generateCores(VCPU_SELECTOR);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
});
$("#CORES_PER_SOCKET", dialogContext).on("change", function(){
_calculateSockets(dialogContext);
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
});
_calculateSockets(dialogContext);
}
else{
$("div.cores_per_socket_select_wrapper", dialogContext).hide();
$("div.socket_info", dialogContext).hide();
CoresPerSocket.calculateSockets(VCPU_SELECTOR);
}
return false;
});
}