From 890b5636d4f81564fdbff050856aba154cf33d10 Mon Sep 17 00:00:00 2001 From: juanmont Date: Tue, 31 Oct 2017 16:58:04 +0100 Subject: [PATCH] B #5518: Sent MEMORY_COST and DIS_COST to OpenNebula in MB (#552) --- .../form-panels/instantiate.js | 6 ++++++ .../form-panels/create/wizard-tabs/general.js | 14 ++++++++++++++ .../tabs/templates-tab/form-panels/instantiate.js | 4 ++++ src/sunstone/public/app/utils/disks-resize.js | 1 - 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js index dffed8d512..a528e04cb5 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js @@ -164,6 +164,12 @@ define(function(require) { delete roleTemplate.APPEND; $.extend(true, that.vm_template_json.VMTEMPLATE.TEMPLATE, roleTemplate); } + if (vm_template_json.VMTEMPLATE.TEMPLATE['MEMORY_COST'] && vm_template_json.VMTEMPLATE.TEMPLATE['MEMORY_UNIT_COST'] && vm_template_json.VMTEMPLATE.TEMPLATE['MEMORY_UNIT_COST'] == "GB") { + vm_template_json.VMTEMPLATE.TEMPLATE['MEMORY_COST'] = vm_template_json.VMTEMPLATE.TEMPLATE['MEMORY_COST']*1024; + } + if (vm_template_json.VMTEMPLATE.TEMPLATE['DISK_COST']) { + vm_template_json.VMTEMPLATE.TEMPLATE['DISK_COST'] = vm_template_json.VMTEMPLATE.TEMPLATE['DISK_COST']*1024; + } var cost = OpenNebulaTemplate.cost(that.vm_template_json); 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 649f934de3..a6a40d4c26 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 @@ -267,10 +267,24 @@ define(function(require) { $.extend(true, templateJSON, CapacityCreate.retrieve($("div.capacityCreate", context))); + if (templateJSON['MEMORY_COST'] && templateJSON['MEMORY_UNIT_COST'] && templateJSON['MEMORY_UNIT_COST'] == "GB") { + templateJSON['MEMORY_COST'] = templateJSON['MEMORY_COST']/1024; + } + if (templateJSON['DISK_COST']) { + templateJSON['DISK_COST'] = templateJSON['DISK_COST']/1024; + } return templateJSON; } function _fill(context, templateJSON) { + + if (templateJSON['MEMORY_COST'] && templateJSON['MEMORY_UNIT_COST'] && templateJSON['MEMORY_UNIT_COST'] == "GB") { + templateJSON['MEMORY_COST'] = templateJSON['MEMORY_COST']*1024; + } + if (templateJSON['DISK_COST']) { + templateJSON['DISK_COST'] = templateJSON['DISK_COST']*1024; + } + that.templateDISKS = $.extend(true, {}, templateJSON.DISK); localStorage.setItem("disksJSON", JSON.stringify(that.templateDISKS)); var sunstone_template = templateJSON.SUNSTONE; diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js index 2c4a929a61..8c74a365ab 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js @@ -501,6 +501,10 @@ define(function(require) { var memoryCost = template_json.VMTEMPLATE.TEMPLATE.MEMORY_COST; var memoryUnitCost = template_json.VMTEMPLATE.TEMPLATE.MEMORY_UNIT_COST; + if (memoryCost && memoryUnitCost && memoryUnitCost == "GB") { + memoryCost = (memoryCost*1024).toString(); + } + if (cpuCost == undefined){ cpuCost = Config.onedConf.DEFAULT_COST.CPU_COST; } diff --git a/src/sunstone/public/app/utils/disks-resize.js b/src/sunstone/public/app/utils/disks-resize.js index 82514d7278..814dcc916d 100644 --- a/src/sunstone/public/app/utils/disks-resize.js +++ b/src/sunstone/public/app/utils/disks-resize.js @@ -30,7 +30,6 @@ define(function(require){ function _calculateCost(context, disk_cost, callback){ var cost = 0; - disk_cost = disk_cost / 1024; $(".diskContainer", context).each(function(){ var size = 0;