mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-09 14:03:20 +09:00
F #1660: Hot memory and vcpu resize
Signed-off-by: Frederick Borges <fborges@opennebula.io>
This commit is contained in:
1 parent
49d80c737a
commit
0db14070ee
7 files changed
+214
-30
No files matched your search
@@ -389,6 +389,14 @@ define(function(require) {
|
||||
if (as_gid){
|
||||
templateJSON["AS_GID"] = as_gid;
|
||||
}
|
||||
|
||||
templateJSON.HOT_RESIZE = {
|
||||
'CPU_HOT_ADD_ENABLED': templateJSON['CPU_HOT_ADD_ENABLED'],
|
||||
'MEMORY_HOT_ADD_ENABLED': templateJSON['MEMORY_HOT_ADD_ENABLED'],
|
||||
}
|
||||
delete templateJSON.CPU_HOT_ADD_ENABLED;
|
||||
delete templateJSON.MEMORY_HOT_ADD_ENABLED;
|
||||
|
||||
return templateJSON;
|
||||
}
|
||||
|
||||
@@ -505,6 +513,16 @@ define(function(require) {
|
||||
delete templateJSON["AS_GID"];
|
||||
}
|
||||
|
||||
if (templateJSON['HOT_RESIZE']){
|
||||
if (templateJSON.HOT_RESIZE['MEMORY_HOT_ADD_ENABLED']){
|
||||
WizardFields.fillInput($('#MEMORY_HOT_ADD_ENABLED',context), templateJSON.HOT_RESIZE['MEMORY_HOT_ADD_ENABLED']);
|
||||
}
|
||||
if (templateJSON.HOT_RESIZE['CPU_HOT_ADD_ENABLED']){
|
||||
WizardFields.fillInput($('#CPU_HOT_ADD_ENABLED',context), templateJSON.HOT_RESIZE['CPU_HOT_ADD_ENABLED']);
|
||||
}
|
||||
delete templateJSON['HOT_RESIZE'];
|
||||
}
|
||||
|
||||
WizardFields.fill(context, templateJSON);
|
||||
}
|
||||
|
||||
|
||||
+53
@@ -201,6 +201,11 @@ define(function(require) {
|
||||
$("div.memory_gb_input input", context).val(_m2g(this.value));
|
||||
});
|
||||
|
||||
// MB to GB, max memory
|
||||
context.on("input", "div.memory_max_input input", function(){
|
||||
$("div.memory_max_gb_input input", context).val(_m2g(this.value));
|
||||
});
|
||||
|
||||
// MB to GB, range input
|
||||
context.on("input", "div.mb_unit input.user_input_params_min", function(){
|
||||
$("div.gb_unit input.user_input_params_min").val(_m2g(this.value));
|
||||
@@ -222,6 +227,11 @@ define(function(require) {
|
||||
$("div.memory_input input", context).val(_g2m(this.value));
|
||||
});
|
||||
|
||||
// GB to MB, max memory
|
||||
context.on("input", "div.memory_max_gb_input input", function(){
|
||||
$("div.memory_max_input input", context).val(_g2m(this.value));
|
||||
});
|
||||
|
||||
// GB to MB, range input
|
||||
context.on("input", "div.gb_unit input.user_input_params_min", function(){
|
||||
$("div.mb_unit input.user_input_params_min").val(_g2m(this.value));
|
||||
@@ -255,6 +265,40 @@ define(function(require) {
|
||||
|
||||
$("#memory_unit", context).change();
|
||||
|
||||
$('#MEMORY_HOT_ADD_ENABLED', context).on('change', function(){
|
||||
if (this.value == 'NO'){
|
||||
$('#memory_max_group', context).hide();
|
||||
}
|
||||
else{
|
||||
$('#memory_max_group', context).show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#CPU_HOT_ADD_ENABLED', context).on('change', function(){
|
||||
if (this.value == 'NO'){
|
||||
$('#vcpu_max_group', context).hide();
|
||||
}
|
||||
else{
|
||||
$('#vcpu_max_group', context).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Unit select
|
||||
$("#MEMORY_MAX_UNIT", context).on("change", function() {
|
||||
var memory_unit_val = $("#MEMORY_MAX_UNIT :selected", context).val();
|
||||
|
||||
if (memory_unit_val == "GB") {
|
||||
$(".mb_max_unit", context).hide();
|
||||
$(".gb_max_unit", context).show();
|
||||
} else {
|
||||
$(".mb_max_unit", context).show();
|
||||
$(".gb_max_unit", context).hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#MEMORY_MAX_UNIT", context).change();
|
||||
|
||||
// Select for memory, cpu, vcpu modification on instantiate
|
||||
$.each(["memory","cpu","vcpu"], function(i,classname){
|
||||
$("."+classname+"_modify_type", context).on("change", function(){
|
||||
@@ -299,6 +343,15 @@ define(function(require) {
|
||||
$("#memory_unit", context).val("GB").change();
|
||||
}
|
||||
|
||||
// Update memory_max_gb with the value set in memory
|
||||
$("div.memory_max_input input", context).trigger("input");
|
||||
|
||||
if ($("div.memory_max_input input", context).val() && $("div.memory_max_input input", context).val() < 1024){
|
||||
$("#memory_max_unit", context).val("MB").change();
|
||||
} else {
|
||||
$("#memory_max_unit", context).val("GB").change();
|
||||
}
|
||||
|
||||
var userInputsJSON = element["USER_INPUTS"];
|
||||
|
||||
if (userInputsJSON) {
|
||||
|
||||
+73
-6
@@ -15,7 +15,7 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<div class="row">
|
||||
<div class="medium-6 small-12 columns">
|
||||
<div class="medium-3 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label class="" for="MEMORY">
|
||||
@@ -45,7 +45,47 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-6 small-12 columns">
|
||||
<div class="medium-2 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label class="" for="MEMORY_HOT_ADD_ENABLED">
|
||||
{{tr "Enable hot resize?"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="small-12 columns">
|
||||
<select id="MEMORY_HOT_ADD_ENABLED" wizard_field="MEMORY_HOT_ADD_ENABLED">
|
||||
<option value="YES">{{tr "yes"}}</option>
|
||||
<option selected value="NO">{{tr "no"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 columns">
|
||||
<div class="row" id="memory_max_group">
|
||||
<div class="small-12 columns">
|
||||
<label class="">
|
||||
{{tr "Max memory"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="small-12 columns">
|
||||
<div class="input-group" style="margin-bottom:0rem;">
|
||||
<div class="mb_max_unit memory_max_input input-group-field">
|
||||
<input type="number" min="0" step="256" wizard_field="MEMORY_MAX" id="MEMORY_MAX"style="margin-bottom:0rem;"/>
|
||||
</div>
|
||||
<div class="gb_max_unit memory_max_gb_input input-group-field">
|
||||
<input id="MEMORY_MAX_GB" type="number" min="0" step="1" name="MEMORY_MAX_GB" style="margin-bottom:0rem;"/>
|
||||
</div>
|
||||
<div class="input-group-button">
|
||||
<select id="MEMORY_MAX_UNIT" name="MEMORY_MAX_UNIT" class="mb_input_unit" style="margin-bottom:0rem;">
|
||||
<option value="MB">{{tr "MB"}}</option>
|
||||
<option value="GB" selected>{{tr "GB"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-5 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label>
|
||||
@@ -93,7 +133,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 small-12 columns">
|
||||
<div class="medium-7 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label class="" for="CPU">
|
||||
@@ -110,7 +150,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-6 small-12 columns not_firecracker">
|
||||
<div class="medium-5 small-12 columns not_firecracker">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label>
|
||||
@@ -141,7 +181,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 small-12 columns">
|
||||
<div class="medium-3 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label class="" for="VCPU">
|
||||
@@ -154,7 +194,34 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-6 small-12 columns">
|
||||
<div class="medium-2 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label class="" for="CPU_HOT_ADD_ENABLED">
|
||||
{{tr "Enable hot resize?"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="small-12 columns">
|
||||
<select id="CPU_HOT_ADD_ENABLED" wizard_field="CPU_HOT_ADD_ENABLED">
|
||||
<option value="YES">{{tr "yes"}}</option>
|
||||
<option selected value="NO">{{tr "no"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 columns">
|
||||
<div class="row" id="vcpu_max_group">
|
||||
<div class="small-12 columns">
|
||||
<label class="">
|
||||
{{tr "Max VCPU"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="small-12 columns">
|
||||
<input type="number" min="0" step="1" id="VCPU_MAX" wizard_field="VCPU_MAX" style="margin-bottom:0rem;"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-5 small-12 columns">
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<label>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="reveal-body">
|
||||
<form id="{{dialogId}}Form" action="">
|
||||
<div class="row centered">
|
||||
<div class="large-6 columns">
|
||||
<div class="enforce_checkbox_wrapper large-6 columns">
|
||||
<input type="checkbox" name="enforce" id="enforce"/>
|
||||
<label class="inline" for="enforce">
|
||||
{{tr "Enforce capacity checks"}}
|
||||
|
||||
@@ -120,13 +120,54 @@ define(function(require) {
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
if (Config.isTabActionEnabled("vms-tab", "VM.resize")) {
|
||||
|
||||
if (that.element.STATE === "3" &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.MEMORY_HOT_ADD_ENABLED === "NO" &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.CPU_HOT_ADD_ENABLED === "NO"){
|
||||
$('#resize_capacity',context).attr("disabled", "disabled");
|
||||
}
|
||||
else if (Config.isTabActionEnabled("vms-tab", "VM.resize")) {
|
||||
context.off("click", "#resize_capacity");
|
||||
context.on("click", "#resize_capacity", function() {
|
||||
var dialog = Sunstone.getDialog(RESIZE_DIALOG_ID);
|
||||
dialog.setElement(that.element);
|
||||
dialog.show();
|
||||
dialogContext = dialog.dialogElement;
|
||||
|
||||
if (that &&
|
||||
that.element &&
|
||||
that.element.STATE &&
|
||||
that.element.STATE === "3"){
|
||||
$('div.cpu_input_wrapper', dialogContext).hide();
|
||||
if (that.element.USER_TEMPLATE &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.MEMORY_HOT_ADD_ENABLED &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.MEMORY_HOT_ADD_ENABLED === "NO"){
|
||||
$('div.enforce_checkbox_wrapper', dialogContext).hide();
|
||||
$('div.memory_input_wrapper', dialogContext).hide();
|
||||
}
|
||||
else{
|
||||
$('div.enforce_checkbox_wrapper', dialogContext).show();
|
||||
$('div.memory_input_wrapper', dialogContext).show();
|
||||
}
|
||||
|
||||
if (that.element.USER_TEMPLATE &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.CPU_HOT_ADD_ENABLED &&
|
||||
that.element.USER_TEMPLATE.HOT_RESIZE.CPU_HOT_ADD_ENABLED === "NO"){
|
||||
$('div.vcpu_input_wrapper', dialogContext).hide();
|
||||
}
|
||||
else{
|
||||
$('div.vcpu_input_wrapper', dialogContext).show();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$('div.cpu_input_wrapper', dialogContext).show();
|
||||
$('div.enforce_checkbox_wrapper', dialogContext).show();
|
||||
$('div.memory_input_wrapper', dialogContext).show();
|
||||
$('div.vcpu_input_wrapper', dialogContext).show();
|
||||
}
|
||||
|
||||
if (that.element.USER_TEMPLATE.HYPERVISOR == "vcenter"){
|
||||
$("div.cores_per_socket_select_wrapper", dialogContext).attr("style", "");
|
||||
$("div.socket_info", dialogContext).show();
|
||||
|
||||
@@ -29,7 +29,7 @@ define(function(require) {
|
||||
["VM.release", "VM.deploy", "VM.updateconf", "VM.terminate_hard", "VM.recover", "VM.resize"];
|
||||
|
||||
STATE_ACTIONS[OpenNebulaVM.STATES.ACTIVE] =
|
||||
["VM.recover","VM.updateconf"];
|
||||
["VM.recover","VM.updateconf","VM.resize"];
|
||||
|
||||
STATE_ACTIONS[OpenNebulaVM.STATES.STOPPED] =
|
||||
["VM.resume", "VM.deploy", "VM.terminate_hard", "VM.recover"];
|
||||
|
||||
@@ -366,7 +366,8 @@ define(function(require) {
|
||||
VCENTER_INSTANCE_ID: {edit: false, delete: false},
|
||||
VCENTER_PASSWORD: {edit: false, delete: false},
|
||||
VCENTER_USER: {edit: false, delete: false},
|
||||
VCENTER_VERSION: {edit: false, delete: false}
|
||||
VCENTER_VERSION: {edit: false, delete: false},
|
||||
HOT_RESIZE: {edit: false, delete: false, show: false}
|
||||
}
|
||||
|
||||
// Helper for fromJSONtoHTMLTable function
|
||||
@@ -393,14 +394,16 @@ define(function(require) {
|
||||
);
|
||||
} else {
|
||||
// if it is a single value, create the row for this occurence of the key
|
||||
str += fromJSONtoHTMLRow(
|
||||
field,
|
||||
current_value,
|
||||
resourceType,
|
||||
false,
|
||||
it,
|
||||
modify
|
||||
);
|
||||
if (!special_restrictions[field] || (special_restrictions[field] && special_restrictions[field]['show'])){
|
||||
str += fromJSONtoHTMLRow(
|
||||
field,
|
||||
current_value,
|
||||
resourceType,
|
||||
false,
|
||||
it,
|
||||
modify
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@@ -418,17 +421,19 @@ define(function(require) {
|
||||
} else {
|
||||
// If it is not comming from a vectorial daddy key, it can still vectorial itself
|
||||
if (typeof value == 'object') {
|
||||
str += '<tr id="' + resourceType.toLowerCase() + '_template_table_' + field + '"><td class="key_td key_vectorial_td">' + Locale.tr(field) + '</td><td class="value_vectorial_td"></td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap"><span id="div_add_vectorial"><a id="div_add_vectorial_' + field + '" class="add_vectorial_a' + ocurrence_str + ' vectorial_key_' + field + '" href="#"><i class="fas fa-plus-sign"/></a></span> <span id="div_minus"><a id="div_minus_' + field + '" class="remove_vectorial_x' + ocurrence_str + '" href="#"><i class="fas fa-trash-alt"/></a></span></td>';
|
||||
if (!special_restrictions[field] || (special_restrictions[field] && special_restrictions[field]['show'])){
|
||||
str += '<tr id="' + resourceType.toLowerCase() + '_template_table_' + field + '"><td class="key_td key_vectorial_td">' + Locale.tr(field) + '</td><td class="value_vectorial_td"></td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap"><span id="div_add_vectorial"><a id="div_add_vectorial_' + field + '" class="add_vectorial_a' + ocurrence_str + ' vectorial_key_' + field + '" href="#"><i class="fas fa-plus-sign"/></a></span> <span id="div_minus"><a id="div_minus_' + field + '" class="remove_vectorial_x' + ocurrence_str + '" href="#"><i class="fas fa-trash-alt"/></a></span></td>';
|
||||
}
|
||||
str += fromJSONtoHTMLTable(
|
||||
value,
|
||||
resourceType,
|
||||
field,
|
||||
ocurrence,
|
||||
modify
|
||||
);
|
||||
}
|
||||
str += fromJSONtoHTMLTable(
|
||||
value,
|
||||
resourceType,
|
||||
field,
|
||||
ocurrence,
|
||||
modify
|
||||
);
|
||||
} else {
|
||||
str += '<tr><td class="key_td">' + Locale.tr(field) + '</td><td class="value_td" id="value_td_input_' + field + '">';
|
||||
str += (field.toLowerCase() === "link")
|
||||
@@ -438,10 +443,10 @@ define(function(require) {
|
||||
if (modify) {
|
||||
var edit_html = "";
|
||||
var delete_html = "";
|
||||
if (!special_restrictions[field] || special_restrictions[field]["edit"]){
|
||||
if (!special_restrictions[field] || (special_restrictions[field] && special_restrictions[field]['edit'])){
|
||||
edit_html = '<span id="div_edit"><a id="div_edit_' + field + '" class="edit_e' + ocurrence_str + '" href="#"><i class="fas fa-edit"/></a></span>';
|
||||
}
|
||||
if (!special_restrictions[field] || special_restrictions[field]["delete"]){
|
||||
if (!special_restrictions[field] || (special_restrictions[field] && special_restrictions[field]["delete"])){
|
||||
delete_html = '<span id="div_minus"><a id="div_minus_' + field + '" class="remove_x' + ocurrence_str + '" href="#"><i class="fas fa-trash-alt"/></a></span>';
|
||||
}
|
||||
str += '<td class="text-right nowrap">' + edit_html + ' ' + delete_html + '</td>';
|
||||
|
||||
Reference in new issue
Block a user