From bb5dbf3800474023db53e17a37bd38c749c9279b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 18 Jul 2016 18:10:57 +0200 Subject: [PATCH] Bug #4638: Add yaml setting to hide CPU input on vm create (cherry picked from commit 58bebe5279978cf45d4edbe484450a8f692a9094) --- src/sunstone/etc/sunstone-views/admin.yaml | 5 ++ .../etc/sunstone-views/admin_vcenter.yaml | 5 ++ src/sunstone/etc/sunstone-views/cloud.yaml | 5 ++ .../etc/sunstone-views/cloud_vcenter.yaml | 5 ++ .../etc/sunstone-views/groupadmin.yaml | 5 ++ .../sunstone-views/groupadmin_vcenter.yaml | 5 ++ src/sunstone/etc/sunstone-views/user.yaml | 5 ++ .../wizard-tabs/general/capacity-inputs.js | 71 ++++++++++++------- 8 files changed, 81 insertions(+), 25 deletions(-) diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 58131a87e6..29276bcac6 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -40,6 +40,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: true + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: false tabs: dashboard-tab: # The following widgets can be used inside any of the '_per_row' settings diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 055b99ceb9..c9ba612c63 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -40,6 +40,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: false + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: false tabs: dashboard-tab: # The following widgets can be used inside any of the '_per_row' settings diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 83e23fdc9e..e61f737682 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -9,6 +9,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: true + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: false tabs: provision-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml index 5a28dc8eb1..9782055c9a 100644 --- a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml @@ -9,6 +9,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: false + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: true tabs: provision-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index 6e5de55392..4602c19977 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -39,6 +39,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: true + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: false tabs: dashboard-tab: # The following widgets can be used inside any of the '_per_row' settings diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index 54c14839ac..b2a7855416 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -39,6 +39,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: false + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: true tabs: dashboard-tab: # The following widgets can be used inside any of the '_per_row' settings diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 32a8a24804..82b9814ad0 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -39,6 +39,11 @@ features: # Allows to change the security groups for each network interface # on the VM creation dialog secgroups: true + + # True to hide the CPU setting in the VM creation dialog. The CPU setting + # will be set to the same value as VCPU, that will still be visible for the + # end users + instantiate_hide_cpu: false tabs: dashboard-tab: # The following widgets can be used inside any of the '_per_row' settings diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js index 78863fafe4..2b6c2a190f 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js @@ -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 Config = require('sunstone-config'); /* TEMPLATES @@ -53,6 +54,10 @@ define(function(require) { } function _setup(context) { + if (Config.isFeatureEnabled("instantiate_hide_cpu")){ + $(".cpu_input_wrapper", context).remove(); + } + Tips.setup(context); } @@ -80,32 +85,34 @@ define(function(require) { var attr; var input; - if (userInputs != undefined && userInputs.CPU != undefined){ - attr = UserInputs.parse("CPU", userInputs.CPU); - } else { - attr = UserInputs.parse("CPU", "O|number-float|||"); + if (!Config.isFeatureEnabled("instantiate_hide_cpu")){ + if (userInputs != undefined && userInputs.CPU != undefined){ + attr = UserInputs.parse("CPU", userInputs.CPU); + } else { + attr = UserInputs.parse("CPU", "O|number-float|||"); + } + + if (element.TEMPLATE.CPU != undefined){ + attr.initial = element.TEMPLATE.CPU; + } else { + attr.mandatory = true; + } + + attr.step = 0.01; + + if(attr.min == undefined){ + attr.min = 0.01; + } + + input = UserInputs.attributeInput(attr); + + if (attr.type != "range-float"){ + $("div.cpu_input_wrapper", context).addClass("medium-6"); + } + + $("div.cpu_input", context).html(input); } - if (element.TEMPLATE.CPU != undefined){ - attr.initial = element.TEMPLATE.CPU; - } else { - attr.mandatory = true; - } - - attr.step = 0.01; - - if(attr.min == undefined){ - attr.min = 0.01; - } - - input = UserInputs.attributeInput(attr); - - if (attr.type != "range-float"){ - $("div.cpu_input_wrapper", context).addClass("medium-6"); - } - - $("div.cpu_input", context).html(input); - if (userInputs != undefined && userInputs.VCPU != undefined){ attr = UserInputs.parse("VCPU", userInputs.VCPU); } else { @@ -173,7 +180,15 @@ define(function(require) { * - VCPU */ function _retrieve(context) { - return WizardFields.retrieve(context); + var values = WizardFields.retrieve(context); + + if (Config.isFeatureEnabled("instantiate_hide_cpu")){ + if(values.VCPU != undefined){ + values.CPU = values.VCPU; + } + } + + return values; } /** @@ -197,6 +212,12 @@ define(function(require) { } }); + if (Config.isFeatureEnabled("instantiate_hide_cpu")){ + if(templateJSON.VCPU != undefined){ + templateJSON.CPU = templateJSON.VCPU; + } + } + return templateJSON; } });