diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 19306d34e3..6819fdf958 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -284,6 +284,26 @@ var create_template_tmpl = '
\
\ \ \ +\ +\ +
\ +
\ +

'+tr("Add swap drive")+'

\ +
\ +
'+tr("Swap")+'\ +
\ + \ + \ +
'+tr("Attach a swap drive of the indicated size MB")+'
\ +
\ +
\ + \ + \ +
'+tr("Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”.")+'
\ +
\ +
\ +
\ +\ \ \ @@ -1542,6 +1562,17 @@ function setupCreateTemplateDialog(){ }; + // Set up the swap section + var swap_setup = function(){ + $('fieldset',section_swap).hide(); + + $('#add_swap',section_swap).click(function(){ + $('fieldset',section_swap).toggle(); + return false; + }); + + }; + // Sets up the network section var networks_setup = function(){ @@ -1755,6 +1786,7 @@ function setupCreateTemplateDialog(){ }; + // Set up the raw section var raw_setup = function(){ $('fieldset',section_raw).hide(); @@ -1837,6 +1869,7 @@ function setupCreateTemplateDialog(){ var section_inputs = $('div#inputs',dialog); var section_graphics = $('div#graphics',dialog); var section_context = $('div#context',dialog); + var section_swap = $('div#swap',dialog); var section_placement = $('div#placement',dialog); var section_raw = $('div#raw',dialog); var section_custom_var = $('div#custom_var',dialog); @@ -1867,6 +1900,7 @@ function setupCreateTemplateDialog(){ os_boot_setup(); features_setup(); disks_setup(); + swap_setup(); networks_setup(); inputs_setup(); graphics_setup(); @@ -1921,6 +1955,20 @@ function setupCreateTemplateDialog(){ scope = section_networks; vm_json["NIC"] = addBoxJSON(scope,'#nics_box'); + //process swap + var swap_size = parseInt($('input[name="swap"]', section_swap).val(),10) + var swap_dev_prefix = $('input[name="swap_dev_prefix"]', section_swap).val() + if (swap_size > 0){ + var swap_obj = { + TYPE: 'swap', + SIZE: swap_size + } + if (swap_dev_prefix) + swap_obj['DEV_PREFIX'] = swap_dev_prefix + + vm_json["NIC"].push(swap_obj); + } + //process inputs -> fetch from box scope = section_inputs; vm_json["INPUT"] = addBoxJSON(scope,'#inputs_box');