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

Merge branch 'feature-498'

This commit is contained in:
Ruben S. Montero 2011-04-26 15:53:04 +02:00
commit 16332042c0
2 changed files with 179 additions and 69 deletions

View File

@ -230,7 +230,7 @@ div.tip span.ui-icon{
div.tip span.man_icon {
display:none;
}
.kvm .man_icon,.xen .man_icon,.img_man .man_icon {
.img_man .man_icon {
display:inline-block!important;
}

View File

@ -40,7 +40,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<ul>\
<li><a href="#easy">Wizard KVM</a></li>\
<li><a href="#easy">Wizard XEN</a></li>\
<li><a href="#manual">VMWare</a></li>\
<li><a href="#easy">Wizard VMware</a></li>\
<li><a href="#manual">Advanced mode</a></li>\
</ul>\
<div id="easy">\
@ -63,22 +63,22 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<h3>Capacity options</h3>\
</div>\
<fieldset><legend>Capacity</legend>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="NAME">Name:</label>\
<input type="text" id="NAME" name="name"/>\
<div class="tip"> Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-&lt;VID&gt;.</div>\
</div>\
<div class="vm_param kvm xen">\
<div class="vm_param kvm xen vmware_opt">\
<label for="MEMORY">Memory:</label>\
<input type="text" id="MEMORY" name="memory" size="4" />\
<div class="tip">Amount of RAM required for the VM, in Megabytes.</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="CPU">CPU:</label>\
<input type="text" id="CPU" name="cpu" size="2"/>\
<div class="tip">Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="VCPU">VCPU:</label>\
<input type="text" id="VCPU" name="vcpu" size="3" />\
<div class="tip">Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.</div>\
@ -93,7 +93,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<h3>Boot/OS options <a id="add_os_boot_opts" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
</div>\
<fieldset><legend>OS and Boot options</legend>\
<div class="vm_param kvm">\
<div class="vm_param kvm vmware">\
<label for="ARCH">Architecture:</label>\
<select id="ARCH" name="arch">\
<option value="i686">i686</option>\
@ -140,10 +140,6 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<div class="vm_param kvm">\
<label for="BOOT">Boot:</label>\
<select id="BOOT" name="boot">\
<option value="hd">hd</option>\
<option value="fd">fd</option>\
<option value="cdrom">cdrom</option>\
<option value="network">network</option>\
</select>\
<div class="tip">Boot device type</div>\
</div>\
@ -168,43 +164,35 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<!--<label for="add_image">Add an image</label>-->\
</div>\
<div class="clear"></div>\
<div class="vm_param kvm xen add_image">\
<div class="vm_param kvm xen vmware add_image">\
<label for="IMAGE">Image:</label>\
<select type="text" id="IMAGE_ID" name="image_id">\
</select>\
<div class="tip">Name of the image to use</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="BUS">Bus:</label>\
<select id="BUS" name="bus">\
<option value="ide">IDE</option>\
<option value="scsi">SCSI</option>\
</select>\
<div class="tip">Type of disk device to emulate: ide, scsi</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware">\
<label for="TARGET">Target:</label>\
<input type="text" id="TARGET" name="target" />\
<div class="tip"> Device to map image disk. If set, it will overwrite the default device mapping</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="DRIVER">Driver:</label>\
<input type="text" id="DRIVER" name="driver" />\
<div class="tip">Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported</div>\
</div>\
<div class="vm_param kvm_opt xen_opt add_disk">\
<div class="vm_param kvm_opt xen_opt vmware_opt add_disk">\
<label for="TYPE">Type:</label>\
<select id="TYPE" name="type">\
<option value="disk">Disk</option>\
<option value="floppy">Floppy</option>\
<option value="cdrom">CD-ROM</option>\
<option value="swap">Swap</option>\
<option value="fs">FS</option>\
<option value="block">Block</option>\
</select>\
<div class="tip">Disk type</div>\
</div>\
<div class="vm_param kvm xen add_disk">\
<div class="vm_param kvm xen vmware add_disk">\
<label for="SOURCE">Source:</label>\
<input type="text" id="SOURCE" name="source" />\
<div class="tip">Disk file location path or URL</div>\
@ -213,7 +201,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<!--Mandatory for swap, fs and block images-->\
<label for="SIZE">Size:</label>\
<input type="text" id="SIZE" name="size" />\
<div class="tip">Disk file location path or URL. Mandatory for swap, fs and block images</div>\
<div class="tip">Size in MB</div>\
</div>\
<div class="vm_param kvm_opt xen_opt add_disk ">\
<!--mandatory for fs images-->\
@ -221,7 +209,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<input type="text" id="FORMAT" name="format" />\
<div class="tip">Filesystem type for the fs images</div>\
</div>\
<div class="vm_param kvm_opt xen_opt add_disk">\
<div class="vm_param kvm_opt xen_opt vmware_opt add_disk">\
<label for="CLONE">Clone:</label>\
<select id="CLONE" name="clone">\
<option value="yes">Yes</option>\
@ -229,7 +217,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
</select>\
<div class="tip">Clone this image</div>\
</div>\
<div class="vm_param kvm_opt xen_opt add_disk">\
<div class="vm_param kvm_opt xen_opt vmware_opt add_disk">\
<label for="SAVE">Save:</label>\
<select id="SAVE" name="save">\
<option value="no">No</option>\
@ -237,7 +225,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
</select>\
<div class="tip">Save this image after shutting down the VM</div>\
</div>\
<div class="vm_param kvm_opt xen_opt add_disk">\
<div class="vm_param kvm_opt xen_opt vmware_opt add_disk">\
<label for="READONLY">Read only:</label>\
<select id="READONLY" name="readonly">\
<option value="no">No</option>\
@ -273,7 +261,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<!--<div class="tip"></div>-->\
</div>\
<div class="clear"></div>\
<div class="vm_param kvm xen network">\
<div class="vm_param kvm xen vmware network">\
<label for="NETWORK">Network:</label>\
<select type="text" id="NETWORK_ID" name="network_id">\
</select>\
@ -284,27 +272,27 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<input type="text" id="IP" name="ip" />\
<div class="tip">Request an specific IP from the Network</div>\
</div>\
<div class="vm_param kvm_opt xen_opt niccfg">\
<div class="vm_param kvm_opt xen_opt vmware_opt niccfg">\
<label for="MAC">MAC:</label>\
<input type="text" id="MAC" name="mac" />\
<div class="tip">HW address associated with the network interface</div>\
</div>\
<div class="vm_param kvm_opt xen_opt niccfg">\
<div class="vm_param kvm_opt xen_opt vmware_opt niccfg">\
<label for="BRIDGE">Bridge</label>\
<input type="text" id="BRIDGE" name="bridge" />\
<div class="tip"> Name of the bridge the network device is going to be attached to</div>\
</div>\
<div class="vm_param kvm_opt niccfg">\
<div class="vm_param kvm_opt vmware_opt niccfg">\
<label for="TARGET">Target:</label>\
<input type="text" id="TARGET" name="nic_target" />\
<div class="tip">Name for the tun device created for the VM</div>\
</div>\
<div class="vm_param kvm_opt niccfg">\
<div class="vm_param kvm_opt vmware_opt niccfg">\
<label for="SCRIPT">Script:</label>\
<input type="text" id="SCRIPT" name="script" />\
<div class="tip">Name of a shell script to be executed after creating the tun device for the VM</div>\
</div>\
<div class="vm_param kvm_opt xen_opt niccfg">\
<div class="vm_param kvm_opt xen_opt vmware_opt niccfg">\
<label for="MODEL">Model:</label>\
<input type="text" id="MODEL" name="model" />\
<div class="tip">Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.</div>\
@ -401,24 +389,24 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<h3>Add context variables <a id="add_context" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
</div>\
<fieldset><legend>Context</legend>\
<div class="vm_param kvm_opt xen_opt">\
<label for="var_name">Name:</label>\
<input type="text" id="var_name" name="var_name" />\
<div class="tip">Name for the context variable</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<label for="var_value">Value:</label>\
<input type="text" id="var_value" name="var_value" />\
<div class="tip">Value of the context variable</div>\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="var_name">Name:</label>\
<input type="text" id="var_name" name="var_name" />\
<div class="tip">Name for the context variable</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<label for="var_value">Value:</label>\
<input type="text" id="var_value" name="var_value" />\
<div class="tip">Value of the context variable</div>\
</div>\
<div class="">\
<button class="add_remove_button add_button" id="add_context_button" value="add_context">Add</button>\
<button class="add_remove_button" id="remove_context_button" value="remove_input">Remove selected</button>\
<div class="clear"></div>\
<label for="context_box">Current variables:</label>\
<select id="context_box" name="context_box" style="width:150px;height:100px;" multiple>\
</select>\
</div>\
<div class="">\
<button class="add_remove_button add_button" id="add_context_button" value="add_context">Add</button>\
<button class="add_remove_button" id="remove_context_button" value="remove_input">Remove selected</button>\
<div class="clear"></div>\
<label for="context_box">Current variables:</label>\
<select id="context_box" name="context_box" style="width:150px;height:100px;" multiple>\
</select>\
</div>\
</fieldset>\
</div>\
\
@ -429,12 +417,12 @@ var create_template_tmpl = '<div id="template_create_tabs">\
<h3>Add placement options <a id="add_placement" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
</div>\
<fieldset><legend>Placement</legend>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="REQUIREMENTS">Requirements:</label>\
<input type="text" id="REQUIREMENTS" name="requirements" />\
<div class="tip">Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="RANK">Rank:</label>\
<input type="text" id="RANK" name="rank" />\
<div class="tip"> This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others</div>\
@ -450,7 +438,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
</div>\
<fieldset><legend>Raw</legend>\
<!--set TYPE to current xen/kvm -->\
<div class="vm_param kvm_opt xen_opt">\
<div class="vm_param kvm_opt xen_opt vmware_opt">\
<label for="DATA">Data:</label>\
<input type="hidden" id="TYPE" name="type" />\
<input type="text" id="DATA" name="data" />\
@ -915,11 +903,37 @@ function setupCreateTemplateDialog(){
enable_xen();
break;
case 2:
break;
enable_vmware();
case 3:
break;
}
//hide_disabled();
//show_enabled();
}
//~ var hide_disabled = function(context) {
//~ var $disabled;
//~ if (!context) {
//~ $disabled = $('.vm_param input:disabled,.vm_param select:disabled');
//~ } else {
//~ $disabled = $('.vm_param input:disabled,.vm_param select:disabled',context);
//~ }
//~
//~ $disabled.each(function(){
//~ $(this).parent('.vm_param').hide();
//~ });
//~ }
//~
//~ var show_enabled = function(context){
//~ var $enabled;
//~ if (!context) {
//~ $enabled = $('.vm_param input:enabled,.vm_param select:enabled');
//~ } else {
//~ $enabled = $('.vm_param input:enabled,.vm_param select:enabled',context);
//~ }
//~
//~ $enabled.parent('.vm_param').show();
//~ }
//Using kvm wizard. Updates mandatory tag, optional tags, disable
//XEN-only (and others) items, enables KVM items
@ -927,8 +941,10 @@ function setupCreateTemplateDialog(){
man_class="kvm";
opt_class="kvm_opt";
$(xen_items).attr("disabled","disabled");
$(vmware_items).attr("disabled","disabled");
$(kvm_items).removeAttr("disabled");
//$(items+':disabled').hide();
$('.vm_param .man_icon').css("display","none");
$('.kvm .man_icon').css("display","inline-block");
//KVM particularities:
@ -936,35 +952,59 @@ function setupCreateTemplateDialog(){
// * Add driver default option for boot and select it - hide some fields
// * Set the raw type to kvm
// * Show the inputs section
$('div#disks select#TYPE option:selected').removeAttr("selected");
$('div#disks select#TYPE').prepend(
'<option id="no_type" value="">None</option>');
$('div#disks select#TYPE option#no_type').attr("selected","selected");
var type_opts =
'<option id="no_type" value="" selected="selected">None</option>\
<option value="disk">Disk</option>\
<option value="floppy">Floppy</option>\
<option value="cdrom">CD-ROM</option>\
<option value="swap">Swap</option>\
<option value="fs">FS</option>\
<option value="block">Block</option>';
$('div#disks select#TYPE').html(type_opts);
var boot_opts =
'<option value="hd">hd</option>\
<option value="fd">fd</option>\
<option value="cdrom">cdrom</option>\
<option value="network">network</option>';
$('div#os_boot_opts select#BOOT').html(boot_opts);
$('div#kernel_bootloader',section_os_boot).show();
$('select#boot_method option').removeAttr("selected");
$('select#boot_method option#no_boot').html("Driver default");
$('select#boot_method option').removeAttr("selected");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
$('div#disks select#BUS').append(
'<option id="virtio" value="virtio">virtio</option>');
var bus_opts =
'<option value="ide">IDE</option>\
<option value="scsi">SCSI</option>\
<option value="virtio">Virtio</option>';
$('div#disks select#BUS').html(bus_opts);
$('input#TYPE', section_raw).val("kvm");
$(section_inputs).show();
$(section_graphics).show();
};
// Using XEN wizard. Update mandatory and optional classes, disable
// KVM-only (and other) items, enable XEN fields...
enable_xen = function(){
var enable_xen = function(){
man_class="xen";
opt_class="xen_opt";
$(kvm_items).attr("disabled","disabled");
$(kvm_items).css("background","");
$(vmware_items).attr("disabled","disabled");
$(xen_items).removeAttr("disabled");
//$(items+':disabled').hide();
$('.vm_param .man_icon').css("display","none");
$('.xen .man_icon').css("display","inline-block");
// XEN particularities:
@ -972,18 +1012,82 @@ function setupCreateTemplateDialog(){
// * Remove driver default boot method
// * Set the raw section to XEN
// * Hide the inputs section
$('div#disks select#TYPE option#no_type').remove();
var type_opts =
'<option value="disk">Disk</option>\
<option value="floppy">Floppy</option>\
<option value="cdrom">CD-ROM</option>\
<option value="swap">Swap</option>\
<option value="fs">FS</option>\
<option value="block">Block</option>';
$('div#disks select#TYPE').html(type_opts);
$('div#os_boot_opts select#BOOT').empty();
$('div#kernel_bootloader',section_os_boot).show();
$('select#boot_method option:selected').removeAttr("selected");
$('select#boot_method option#no_boot').html("Please choose");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
$('div#disks select#BUS option#virtio').remove();
var bus_opts =
'<option value="ide">IDE</option>\
<option value="scsi">SCSI</option>';
$('div#disks select#BUS').html(bus_opts);
$('input#TYPE', section_raw).val("xen");
$(section_inputs).hide(); //not present for xen
$(section_graphics).show();
};
var enable_vmware = function() {
man_class="vmware";
opt_class="vmware_opt";
$(xen_items).attr("disabled","disabled");
$(kvm_items).attr("disabled","disabled");
$(vmware_items).removeAttr("disabled");
$('.vm_param .man_icon').css("display","none");
$('.vmware .man_icon').css("display","inline-block");
//VMWARE particularities
// * Add no_type option for disks
// * Set the raw type to kvm
// * Hide the inputs and graphics section
// * Hide boot method
var type_opts =
'<option value="file" selected="selected">File</option>\
<option value="cdrom">CD-ROM</option>\
<option value="block">Block</option>';
$('div#os_boot_opts select#BOOT').empty();
$('div#disks select#BOOT').empty();
$('select#boot_method option').removeAttr("selected");
$('select#boot_method option#no_boot').html("Driver default");
$('select#boot_method option').removeAttr("selected");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
var bus_opts =
'<option value="ide">IDE</option>\
<option value="scsi">SCSI</option>';
$('div#disks select#BUS').html(bus_opts);
$('input#TYPE', section_raw).val("vmware");
$(section_inputs).hide();
$(section_graphics).hide();
$('div#kernel_bootloader',section_os_boot).hide();
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
}
//This function checks that all mandatory items within a section
//have some value. Returns true if so, false if not.
var mandatory_filter = function(context){
@ -1217,6 +1321,7 @@ function setupCreateTemplateDialog(){
$('#FORMAT',section_disks).parent().hide();
$('#SIZE',section_disks).parent().attr("disabled","disabled");
$('#TYPE :selected',section_disks).removeAttr("selected");
//hide_disabled(section_disks);
});
//Chrome workaround
@ -1294,6 +1399,7 @@ function setupCreateTemplateDialog(){
$('#FORMAT',section_disks).parent().hide();
$('#FORMAT',section_disks).parent().attr("disabled","disabled");
}
//hide_disabled(section_disks);
});
//Our filter for the disks section fields is the mandatory
@ -1342,6 +1448,7 @@ function setupCreateTemplateDialog(){
$('.niccfg',section_networks).removeAttr("disabled");
break;
}
//hide_disabled(section_networks);
});
//The filter to add a new network checks that we have selected a
@ -1520,13 +1627,16 @@ function setupCreateTemplateDialog(){
var section_raw = $('#raw');
//Different selector for items of kvm and xen (mandatory and optional)
var items = '.vm_section input,.vm_section select';
var items = '.vm_param input,.vm_param select';
var kvm_man_items = '.kvm input,.kvm select';
var kvm_opt_items = '.kvm_opt input, .kvm_opt select';
var kvm_items = kvm_man_items +','+kvm_opt_items;
var xen_man_items = '.xen input,.xen select';
var xen_opt_items = '.xen_opt input, .xen_opt select';
var xen_items = xen_man_items +','+ xen_opt_items;
var vmware_man_items = '.vmware input,.vmware select';
var vmware_opt_items = '.vmware_opt input, .vmware_opt select';
var vmware_items = vmware_man_items +','+ vmware_opt_items;
//Starting template type, optional items class and mandatory items class
var templ_type = "kvm";