1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

F #4474: Cores vCenter (#4658)

This commit is contained in:
Frederick Borges 2020-05-05 16:49:24 +02:00 committed by GitHub
parent a3ce23ef5c
commit 5b1b2d4868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 254 additions and 11 deletions

View File

@ -1053,6 +1053,19 @@ define(function(require) {
$.extend(extra_info.template, user_inputs_values);
}
var topology = {}
if (extra_info && extra_info.template && extra_info.template.CORES){
topology.CORES = extra_info["template"]["CORES"];
topology.SOCKETS = parseInt(extra_info["template"]["VCPU"]) / parseInt(extra_info["template"]["CORES"]);
topology.THREADS = 1;
delete extra_info["template"]["CORES"];
}
if (!$.isEmptyObject(topology)){
extra_info.template.TOPOLOGY = topology;
}
var action;
if ($("input.instantiate_pers", context).prop("checked")){

View File

@ -188,6 +188,16 @@ define(function(require) {
delete templateJSON["TOPOLOGY"]["MEMORY_ACCESS"];
}
if (templateJSON["CORES"]){
if (!templateJSON["TOPOLOGY"]){
templateJSON["TOPOLOGY"] = {};
}
templateJSON["TOPOLOGY"]["CORES"] = templateJSON["CORES"];
templateJSON["TOPOLOGY"]["SOCKETS"] = parseInt(templateJSON["VCPU"]) / parseInt(templateJSON["CORES"]);
templateJSON["TOPOLOGY"]["THREADS"] = 1;
delete templateJSON["CORES"];
}
// 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.

View File

@ -145,6 +145,35 @@ define(function(require) {
_totalCost();
}
<<<<<<< Updated upstream
=======
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();
}
}
>>>>>>> Stashed changes
function _setup(context) {
context.on("change", "#MEMORY", function() {
_calculatedRealMemory(context);
@ -162,6 +191,15 @@ define(function(require) {
_calculatedRealCpu(context);
});
context.on("change", "#VCPU", function(){
_generateCores(context);
_calculateSockets(context);
});
context.on("change", "#CORES_PER_SOCKET", function(){
_calculateSockets(context);
});
// MB to GB
context.on("input", "div.memory_input input", function(){
$("div.memory_gb_input input", context).val(_m2g(this.value));

View File

@ -97,7 +97,7 @@
<div class="row">
<div class="small-12 columns">
<label class="" for="CPU">
{{tr "CPU"}}
{{tr "Physical CPU"}}
{{{tip (tr "Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.")}}}
</label>
<div class="cpu_input">
@ -145,7 +145,7 @@
<div class="row">
<div class="small-12 columns">
<label class="" for="VCPU">
{{tr "VCPU"}}
{{tr "Virtual CPU"}}
{{{tip (tr "Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")}}}
</label>
<div class="vcpu_input">
@ -183,4 +183,28 @@
</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

@ -61,6 +61,31 @@ define(function(require) {
Tips.setup(context);
}
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()));
}
}
}
/**
* Fills the capacity inputs
* @param {Object} context JQuery selector
@ -106,7 +131,7 @@ define(function(require) {
input = UserInputs.attributeInput(attr);
if (attr.type != "range-float"){
$("div.cpu_input_wrapper", context).addClass("medium-6");
$("div.cpu_input_wrapper", context).addClass("small-12");
}
$("div.cpu_input", context).html(input);
@ -128,7 +153,7 @@ define(function(require) {
input = UserInputs.attributeInput(attr);
if (attr.type != "range"){
$("div.vcpu_input_wrapper", context).addClass("medium-6");
$("div.vcpu_input_wrapper", context).addClass("small-12");
}
$("div.vcpu_input", context).html(input);
@ -151,6 +176,34 @@ define(function(require) {
});
}
if (element.TEMPLATE.HYPERVISOR == "vcenter"){
$("div.cores_per_socket_select_wrapper").show();
$("div.socket_info").show();
var vcpuValue = $("div.vcpu_input input", context).val();
if (vcpuValue !== "") {
_generateCores(context);
$('#CORES_PER_SOCKET option[value="' + element.TEMPLATE.CORES_PER_SOCKET + '"]').prop('selected', true);
}
$("div.vcpu_input input", context).on("change", function(){
_generateCores(context);
$('#CORES_PER_SOCKET option[value=""]').prop('selected', true);
_calculateSockets(context);
});
$("#CORES_PER_SOCKET", context).on("change", function(){
_calculateSockets(context);
})
_calculateSockets(context);
}
else{
$("div.cores_per_socket_select_wrapper").hide();
$("div.socket_info").hide();
}
if (userInputs != undefined && userInputs.MEMORY != undefined){
attr = UserInputs.parse("MEMORY", userInputs.MEMORY);
} else {

View File

@ -30,7 +30,7 @@
<div class="row">
<div class="cpu_input_wrapper small-12 columns">
<label style="padding: 0; text-align: left" class="small-5 columns" for="CPU">
{{tr "CPU"}}
{{tr "Physical CPU"}}
{{{tip (tr "Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.")}}}
</label>
<label style="padding: 0; text-align: right" class="small-7 columns" id="quotas-cpu" hidden>
@ -40,10 +40,28 @@
</div>
<div class="vcpu_input_wrapper small-12 columns end">
<label class="" for="VCPU">
{{tr "VCPU"}}
{{tr "Virtual CPU"}}
{{{tip (tr "Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")}}}
</label>
<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

@ -90,8 +90,8 @@ define(function(require) {
/*
FUNCTION DEFINITIONS
*/
function _html() {
function _html() {
return TemplateHTML({
"formPanelId": this.formPanelId
});
@ -407,6 +407,19 @@ define(function(require) {
capacityContext = $(".capacityContext" + template_id, context);
$.extend(tmp_json, CapacityInputs.retrieveChanges(capacityContext));
var topology = {}
if (tmp_json && tmp_json.CORES){
topology.CORES = tmp_json["CORES"];
topology.SOCKETS = parseInt(tmp_json["VCPU"]) / parseInt(tmp_json["CORES"]);
topology.THREADS = 1;
delete tmp_json["CORES"];
}
if (!$.isEmptyObject(topology)){
tmp_json.TOPOLOGY = topology;
}
extra_info["template"] = tmp_json;
for (var i = 0; i < n_times_int; i++) {
extra_info["vm_name"] = vm_name.replace(/%i/gi, i); // replace wildcard

View File

@ -77,6 +77,19 @@ define(function(require) {
var enforce = $("#enforce", this).is(":checked");
var topology = {}
if (templateJSON && templateJSON.CORES){
topology.CORES = templateJSON["CORES"];
topology.SOCKETS = parseInt(templateJSON["VCPU"]) / parseInt(templateJSON["CORES"]);
topology.THREADS = 1;
delete templateJSON["CORES"];
}
if (!$.isEmptyObject(topology)){
templateJSON.TOPOLOGY = topology;
}
var obj = {
"vm_template": templateJSON,
"enforce": enforce,

View File

@ -84,7 +84,7 @@ define(function(require) {
if (memoryCost == undefined){
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
}
console.log("element ->",this.element);
return TemplateInfo({
'element': this.element,
'resizeStateEnabled': resizeStateEnabled,
@ -93,6 +93,32 @@ 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;
if (Config.isTabActionEnabled("vms-tab", "VM.resize")) {
@ -101,6 +127,32 @@ define(function(require) {
var dialog = Sunstone.getDialog(RESIZE_DIALOG_ID);
dialog.setElement(that.element);
dialog.show();
dialogContext = dialog.dialogElement;
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 !== "") {
_generateCores(dialogContext);
$('#CORES_PER_SOCKET option[value="' + that.element.TEMPLATE.TOPOLOGY.CORES + '"]').prop('selected', true);
}
$("div.vcpu_input input", dialogContext).on("change", function(){
_generateCores(dialogContext);
_calculateSockets(dialogContext);
});
$("#CORES_PER_SOCKET", dialogContext).on("change", function(){
_calculateSockets(dialogContext);
})
_calculateSockets(dialogContext);
}
else{
$("div.cores_per_socket_select_wrapper", dialogContext).hide();
$("div.socket_info", dialogContext).hide();
}
return false;
});
}

View File

@ -19,8 +19,11 @@
<table class="info_table dataTable">
<thead>
<tr>
<th>{{tr "CPU"}}</th>
<th>{{tr "VCPU"}}</th>
<th>{{tr "Physical CPU"}}</th>
<th>{{tr "Virtual CPU"}}</th>
{{#ifEquals element.USER_TEMPLATE.HYPERVISOR "vcenter"}}
<th>{{tr "Virtual Cores"}}</th>
{{/ifEquals}}
<th>{{tr "Memory"}}</th>
{{#isFeatureEnabled "showback"}}
<th>{{tr "Cost / CPU"}}</th>
@ -33,6 +36,12 @@
<tr>
<td id="cpu_info">{{valOrDefault element.TEMPLATE.CPU '-'}}</td>
<td id="vcpu_info">{{valOrDefault element.TEMPLATE.VCPU '-'}}</td>
{{#ifEquals element.USER_TEMPLATE.HYPERVISOR "vcenter"}}
<td id="cores_info">
{{valOrDefault element.TEMPLATE.TOPOLOGY.CORES '-'}} Cores x
{{valOrDefault element.TEMPLATE.TOPOLOGY.SOCKETS '-'}} Sockets
</td>
{{/ifEquals}}
<td id="memory_info">{{humanizeSize "MB" element.TEMPLATE.MEMORY}}</td>
{{#isFeatureEnabled "showback"}}
<td id="cpu_cost_info">{{cpuCost}}</td>