From 0db14070eedff9401536dbfb83ef61a8ff99a2fa Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Thu, 17 Dec 2020 17:55:51 +0100 Subject: [PATCH] F #1660: Hot memory and vcpu resize Signed-off-by: Frederick Borges --- .../form-panels/create/wizard-tabs/general.js | 18 +++++ .../wizard-tabs/general/capacity-create.js | 53 +++++++++++++ .../general/capacity-create/html.hbs | 79 +++++++++++++++++-- .../app/tabs/vms-tab/dialogs/resize/html.hbs | 2 +- .../app/tabs/vms-tab/panels/capacity.js | 43 +++++++++- .../app/tabs/vms-tab/utils/state-actions.js | 2 +- .../public/app/utils/panel/template-table.js | 47 ++++++----- 7 files changed, 214 insertions(+), 30 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js index 75fe712c02..8ac96fbf36 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js @@ -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); } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create.js index cf0fa3a65a..355f94768b 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create.js @@ -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) { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create/html.hbs index 4cb7941f06..ceb6715728 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-create/html.hbs @@ -15,7 +15,7 @@ {{! -------------------------------------------------------------------------- }}
-
+
-
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
-
+
-
+
-
+
-
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+