1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

Feature #1403: Support adding a swap disk in VM template wizard

(cherry picked from commit 4dfe1f08bf5f87fb7f749f35bd3cb2a6b2fd39a2)
This commit is contained in:
Hector Sanjuan 2012-08-28 18:14:32 +02:00 committed by Ruben S. Montero
parent fec2cbb07f
commit 31e39b128e

View File

@ -284,6 +284,26 @@ var create_template_tmpl = '<div id="template_create_tabs">\
</div>\
</fieldset>\
</div>\
\
\
<div class="vm_section" id="swap">\
<div class="show_hide" id="add_swap_cb">\
<h3>'+tr("Add swap drive")+' <a id="add_swap" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
</div>\
<fieldset><legend>'+tr("Swap")+'</legend>\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="swap">'+tr("Swap size (MB)")+':</label>\
<input type="text" name="swap" value="0" />\
<div class="tip">'+tr("Attach a swap drive of the indicated size MB")+'</div>\
</div>\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="swap_dev_prefix">'+tr("Dev prefix")+':</label>\
<input type="text" name="swap_dev_prefix" />\
<div class="tip">'+tr("Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”.")+'</div>\
</div>\
</fieldset>\
</div>\
\
\
<!-- network section network, network id,, ip, mac,\
bridge, target, script, model -->\
@ -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');