diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..5f23cb1d70 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.a +*.o +*.pyc +.xmlrpc_test/ +.sconsign.dblite +share/man/*.gz +src/im_mad/collectd/collectd +src/scheduler/src/sched/.xmlrpc_test/ +src/scheduler/src/sched/mm_sched +src/sunstone/locale/languages/*.js +src/mad/utils/tty_expect +src/nebula/.xmlrpc_test/ +src/nebula/oned diff --git a/src/datastore_mad/remotes/libfs.sh b/src/datastore_mad/remotes/libfs.sh index 6e5b0cf9b9..b7e64ab500 100644 --- a/src/datastore_mad/remotes/libfs.sh +++ b/src/datastore_mad/remotes/libfs.sh @@ -154,25 +154,18 @@ function gzip_file_size { function fs_size { case $1 in - http://*/download|https://*/download) - BASE_URL=${1%%/download} - HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1` + http://*) + HEADERS=`curl -LIk $1 2>&1` - echo $HEADERS | grep "market" > /dev/null 2>&1 - - if [ $? -eq 0 ]; then - #URL is from market place - SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1|grep -E "^ *\"size\": \"?[0-9]+\"?.$"|tr -dc 0-9` + if echo "$HEADERS" | grep -q "OpenNebula-AppMarket-Size"; then + # An AppMarket/Marketplace URL + SIZE=$(echo "$HEADERS" | grep "^OpenNebula-AppMarket-Size:" | tail -n1 | cut -d: -f2) else - #Not a marketplace URL - SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2` + # Not an AppMarket/Marketplace URL + SIZE=$(echo "$HEADERS" | grep "^Content-Length:" | tail -n1 | cut -d: -f2) fi error=$? ;; - http://*|https://*) - SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2` - error=$? - ;; *) if [ -d "$1" ]; then SIZE=`du -sb "$1" | cut -f1` @@ -195,6 +188,8 @@ function fs_size { ;; esac + SIZE=$(echo $SIZE | tr -d "\r") + if [ $error -ne 0 ]; then SIZE=0 else diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index 5a3e7b90a2..d80322bde2 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -18,28 +18,14 @@ #include #include #include +#include +#include +#include #include "Nebula.h" using namespace std; -/* ------------------------------------------------------------------------- */ -/* GLOBAL VARIABLES */ -/* ------------------------------------------------------------------------- */ - -static const char * usage = -"\n oned [-h] [-v] [-f]\n\n" -"SYNOPSIS\n" -" Starts the OpenNebula daemon\n\n" -"OPTIONS\n" -"\t-v\tprints OpenNebula version and license\n" -"\t-h\tprints this help.\n" -"\t-f\tforeground, do not fork the oned daemon\n" -"\t-i\tinitialize the dabase and exit.\n"; - -static const char * susage = -"usage: oned [-h] [-v] [-f]\n"; - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -51,6 +37,25 @@ static void print_license() << "(http://www.apache.org/licenses/LICENSE-2.0).\n"; } +static void print_usage(ostream& str) +{ + str << "Usage: oned [-h] [-v] [-f] [-i]\n"; +} + +static void print_help() +{ + print_usage(cout); + + cout << "\n" + << "SYNOPSIS\n" + << " Starts the OpenNebula daemon\n\n" + << "OPTIONS\n" + << " -v, --verbose\toutput version information and exit\n" + << " -h, --help\tdisplay this help and exit\n" + << " -f, --foreground\tforeground, do not fork the oned daemon\n" + << " -i, --init-db\tinitialize the dabase and exit\n"; +} + /* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ @@ -100,7 +105,19 @@ int main(int argc, char **argv) string wd; int rc; - while((opt = getopt(argc,argv,"vhif")) != -1) + static struct option long_options[] = { + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {"foreground", no_argument, 0, 'f'}, + {"init-db", no_argument, 0, 'i'}, + {0, 0, 0, 0} + }; + + int long_index = 0; + + while ((opt = getopt_long(argc, argv, "vhif", + long_options, &long_index)) != -1) + { switch(opt) { case 'v': @@ -108,7 +125,7 @@ int main(int argc, char **argv) exit(0); break; case 'h': - cout << usage; + print_help(); exit(0); break; case 'i': @@ -119,10 +136,11 @@ int main(int argc, char **argv) foreground = true; break; default: - cerr << susage; + print_usage(cerr); exit(-1); break; } + } // --------------------------------- // Check if other oned is running diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 462f826a42..d74d0e2903 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -344,9 +344,12 @@ var image_actions = { "Image.create" : { type: "create", call: OpenNebula.Image.create, - callback: addImageElement, - error: onError, - notify:true + callback: function(request, response){ + addImageElement(request, response); + $create_image_dialog.trigger("reveal:close") + notifyCustom(tr("Image created "), "ID: " + response.IMAGE.ID, false) + }, + error: onError }, "Image.create_dialog" : { @@ -866,26 +869,20 @@ function enable_all_datastores() } // Prepare the image creation dialog -function setupCreateImageDialog(){ +function setupCreateImageDialog(dialog){ dialogs_context.append('
'); $create_image_dialog = $('#create_image_dialog',dialogs_context); var dialog = $create_image_dialog; dialog.html(create_image_tmpl); - setupTips($create_image_dialog); - - var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window - - //Prepare jquery dialog - //dialog.dialog({ - // autoOpen: false, - // modal:true, - // width: 520, - // height: height - //}); dialog.addClass("reveal-modal large max-height"); + initialize_create_image_dialog(dialog); +} + +function initialize_create_image_dialog(dialog) { + setupTips(dialog); $('.advanced',dialog).hide(); $('#advanced_image_create',dialog).click(function(){ @@ -893,32 +890,24 @@ function setupCreateImageDialog(){ return false; }); - //$('#img_tabs',dialog).tabs(); - //$('button',dialog).button(); - //$('#datablock_img',dialog).attr('disabled','disabled'); - - $('select#img_type',dialog).change(function(){ var value = $(this).val(); - var context = $create_image_dialog; + var context = dialog; switch (value){ case "DATABLOCK": $('#datablock_img',context).removeAttr("disabled"); - //$('#empty_datablock', context).show(); break; default: $('#datablock_img',context).attr('disabled','disabled'); - //$('#empty_datablock', context).hide(); $('#path_img',context).click(); } }); - $('#img_path,#img_fstype,#img_size,#file-uploader',dialog).closest('.row').hide(); $("input[name='src_path']", dialog).change(function(){ - var context = $create_image_dialog; + var context = dialog; var value = $(this).val(); switch (value){ case "path": @@ -942,8 +931,8 @@ function setupCreateImageDialog(){ $('#add_custom_var_image_button', dialog).click( function(){ - var name = $('#custom_var_image_name',$create_image_dialog).val(); - var value = $('#custom_var_image_value',$create_image_dialog).val(); + var name = $('#custom_var_image_name',dialog).val(); + var value = $('#custom_var_image_value',dialog).val(); if (!name.length || !value.length) { notifyError(tr("Custom attribute name and value must be filled in")); return false; @@ -951,14 +940,14 @@ function setupCreateImageDialog(){ option= ''; - $('select#custom_var_image_box',$create_image_dialog).append(option); + $('select#custom_var_image_box',dialog).append(option); return false; } ); $('#remove_custom_var_image_button', dialog).click( function(){ - $('select#custom_var_image_box :selected',$create_image_dialog).remove(); + $('select#custom_var_image_box :selected',dialog).remove(); return false; } ); @@ -966,9 +955,7 @@ function setupCreateImageDialog(){ $('#upload-progress',dialog).css({ border: "1px solid #AAAAAA", position: "relative", -// bottom: "29px", width: "258px", -// left: "133px", height: "15px", display: "inline-block" }); @@ -978,7 +965,7 @@ function setupCreateImageDialog(){ // Upload is handled by FileUploader vendor plugin var uploader = new qq.FileUploaderBasic({ - button: $('#file-uploader',$create_image_dialog)[0], + button: $('#file-uploader',dialog)[0], action: 'upload', multiple: false, params: {}, @@ -987,35 +974,11 @@ function setupCreateImageDialog(){ //notifyMessage(message); }, onSubmit: function(id, fileName){ - //set url params - //since the body is the upload, we need the pass - //the image info here uploader.setParams({ img : JSON.stringify(img_obj), file: fileName }); - //we pop up an upload progress dialog - //var pos_top = $(window).height() - 120; - //var pos_left = 220; - //var pb_dialog = $('
'+ - // '
'+ - // '
').dialog({ - // draggable:true, - // modal:false, - // resizable:false, - // buttons:{}, - // width: 460, - // minHeight: 50, - // position: [pos_left, pos_top] - // }); - //var pb_dialog = $('
'+ - // '
'+ - // '
').addClass("reveal-modal"); - - //$('#upload-progress',pb_dialog).progressbar({value:0}); $('#upload_progress_bars').append('
\
\ '+tr("Uploading...")+'\ @@ -1029,8 +992,6 @@ function setupCreateImageDialog(){
'); }, onProgress: function(id, fileName, loaded, total){ - //update upload dialog with current progress - //$('div#pb_dialog #upload-progress').progressbar("option","value",Math.floor(loaded*100/total)); $('span.meter', $('#'+id+'progressBar')).css('width', Math.floor(loaded*100/total)+'%') }, onComplete: function(id, fileName, responseJSON){ @@ -1152,7 +1113,7 @@ function setupCreateImageDialog(){ } //Time to add custom attributes - $('#custom_var_image_box option',$create_image_dialog).each(function(){ + $('#custom_var_image_box option',dialog).each(function(){ var attr_name = $(this).attr('name'); var attr_value = $(this).val(); img_json[attr_name] = attr_value; @@ -1170,8 +1131,6 @@ function setupCreateImageDialog(){ Sunstone.runAction("Image.create", img_obj); }; - $create_image_dialog.trigger("reveal:close") - return false; }); @@ -1192,21 +1151,21 @@ function setupCreateImageDialog(){ "ds_id" : ds_id }; Sunstone.runAction("Image.create",img_obj); - $create_image_dialog.trigger("reveal:close") + return false; }); $('#wizard_image_reset_button').click(function(){ - $create_image_dialog.trigger('reveal:close'); - $create_image_dialog.remove(); + dialog.trigger('reveal:close'); + dialog.remove(); setupCreateImageDialog(); popUpCreateImageDialog(); }); $('#advanced_image_reset_button').click(function(){ - $create_image_dialog.trigger('reveal:close'); - $create_image_dialog.remove(); + dialog.trigger('reveal:close'); + dialog.remove(); setupCreateImageDialog(); popUpCreateImageDialog(); @@ -1214,10 +1173,7 @@ function setupCreateImageDialog(){ }); } -function popUpCreateImageDialog(){ - $('#file-uploader input',$create_image_dialog).removeAttr("style"); - $('#file-uploader input',$create_image_dialog).attr('style','margin:0;width:256px!important'); - +function initialize_datastore_info_create_image_dialog(dialog) { datastores_str = makeSelectOptions(dataTable_datastores, 1, 4, @@ -1226,18 +1182,23 @@ function popUpCreateImageDialog(){ true ); - $('#img_datastore',$create_image_dialog).html(datastores_str); - $('#img_datastore_raw',$create_image_dialog).html(datastores_str); + $('#img_datastore',dialog).html(datastores_str); + $('#img_datastore_raw',dialog).html(datastores_str); - $create_image_dialog.reveal(); - $("input#img_name",$create_image_dialog).focus(); - - $('select#img_datastore').children('option').each(function() { - if ($(this).val() == "2") - { + $('select#img_datastore', dialog).children('option').each(function() { + if ($(this).val() == "2") { $(this).attr('disabled', 'disabled'); } }); + + $('#file-uploader input',dialog).removeAttr("style"); + $('#file-uploader input',dialog).attr('style','margin:0;width:256px!important'); +} + +function popUpCreateImageDialog(){ + initialize_datastore_info_create_image_dialog($create_image_dialog); + $create_image_dialog.reveal(); + $("input#img_name",$create_image_dialog).focus(); } // Set the autorefresh interval for the datatable diff --git a/src/sunstone/public/js/plugins/marketplace-tab.js b/src/sunstone/public/js/plugins/marketplace-tab.js index de36ea2a68..47440ac164 100644 --- a/src/sunstone/public/js/plugins/marketplace-tab.js +++ b/src/sunstone/public/js/plugins/marketplace-tab.js @@ -16,6 +16,7 @@ /* Marketpplace tab plugin */ var dataTable_marketplace; +var $marketplace_import_dialog; var market_actions = { "Marketplace.list" : { @@ -42,36 +43,115 @@ var market_actions = { elements: marketplaceElements, call: OpenNebula.Marketplace.show, callback: function(request,response){ - $('#img_name', $create_image_dialog).val(response['name']); - $('#img_path', $create_image_dialog).val(response['links']['download']['href']); - $('#src_path_select input[value="path"]', $create_image_dialog).trigger('click'); - $('select#img_type', $create_image_dialog).val('OS'); - $('select#img_type', $create_image_dialog).trigger('change'); - - if (response['files'][0]['hypervisor'] == "KVM") { - $('#img_driver', $create_image_dialog).val(response['files'][0]['format']) + if (response['status'] && response['status'] != 'ready') { + notifyError(tr("The appliance is not ready")); + return; } - //remove any options from the custom vars dialog box - $("#custom_var_image_box",$create_image_dialog).empty(); - - var md5 = response['files'][0]['md5'] - if ( md5 ) { - option = ''; - $("#custom_var_image_box",$create_image_dialog).append(option); + if ($marketplace_import_dialog != undefined) { + $marketplace_import_dialog.remove(); } - var sha1 = response['files'][0]['sha1'] - if ( sha1 ) { - option = ''; - $("#custom_var_image_box",$create_image_dialog).append(option); + dialogs_context.append(marketplace_import_dialog); + $marketplace_import_dialog = $('#marketplace_import_dialog',dialogs_context); + $marketplace_import_dialog.addClass("reveal-modal xlarge max-height"); + $marketplace_import_dialog.reveal(); + + var tab_id = 1; + + $.each(response['files'], function(index, value){ + // Append the new div containing the tab and add the tab to the list + var image_dialog = $('
  • '+ + create_image_tmpl + + '
  • ').appendTo($("ul#marketplace_import_dialog_tabs_content")); + + var a_image_dialog = $("
    \ + "+tr("Image")+"\ +
    ").appendTo($("dl#marketplace_import_dialog_tabs")); + + initialize_create_image_dialog(image_dialog); + initialize_datastore_info_create_image_dialog(image_dialog); + + $('#img_name', image_dialog).val(value['name']||response['name']); + $('#img_path', image_dialog).val(response['links']['download']['href']+'/'+index); + $('#src_path_select input[value="path"]', image_dialog).trigger('click'); + $('select#img_type', image_dialog).val(value['type']); + $('select#img_type', image_dialog).trigger('change'); + + //remove any options from the custom vars dialog box + $("#custom_var_image_box",image_dialog).empty(); + + var md5 = value['md5'] + if ( md5 ) { + option = ''; + $("#custom_var_image_box",image_dialog).append(option); + } + + var sha1 = value['sha1'] + if ( sha1 ) { + option = ''; + $("#custom_var_image_box",image_dialog).append(option); + } + + a_image_dialog.on('click', function(){ + $create_image_dialog = image_dialog; + }) + + image_dialog.on("reveal:close", function(){ + a_image_dialog.remove(); + image_dialog.remove(); + if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) { + $('a', $("dl#marketplace_import_dialog_tabs")).first().click(); + } else { + $marketplace_import_dialog.trigger("reveal:close"); + } + return false; + }); + + $("a[href='#img_manual']", image_dialog).closest('dl').remove(); + tab_id++; + }) + + if (response['opennebula_template'] && response['opennebula_template'] !== "CPU=1") { + $create_template_dialog.remove(); + // Template + // Append the new div containing the tab and add the tab to the list + var template_dialog = $('
  • '+ + create_template_tmpl + + '
  • ').appendTo($("ul#marketplace_import_dialog_tabs_content")); + + var a_template_dialog = $("
    \ + "+tr("Template")+"\ +
    ").appendTo($("dl#marketplace_import_dialog_tabs")); + + initialize_create_template_dialog(template_dialog); + fillTemplatePopUp( + JSON.parse(response['opennebula_template']), + template_dialog); + + a_template_dialog.on('click', function(){ + $create_template_dialog = template_dialog; + }) + + template_dialog.on("reveal:close", function(){ + a_template_dialog.remove(); + template_dialog.remove(); + if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) { + $('a', $("dl#marketplace_import_dialog_tabs")).first().click(); + } else { + $marketplace_import_dialog.trigger("reveal:close"); + } + return false; + }); + + $("a[href='#manual']", template_dialog).closest('dl').remove(); } - popUpCreateImageDialog(); + $('a', $("dl#marketplace_import_dialog_tabs")).first().click(); }, error: onError }, @@ -97,6 +177,20 @@ var market_buttons = { } }; +var marketplace_import_dialog = +'
    '+ + '
    '+ + '

    '+tr("Import Appliance")+'

    '+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + '
      '+ + '
    '+ + '
    '+ + '×'+ +'
    '; + var marketplace_tab_content = '\
    \
    \ diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 75951232d5..cfd8296740 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -311,9 +311,13 @@ var template_actions = { "Template.create" : { type: "create", call: OpenNebula.Template.create, - callback: addTemplateElement, - error: onError, - notify:true + callback: function(request, response){ + $create_template_dialog.trigger("reveal:close") + $create_template_dialog.empty(); + addTemplateElement(request, response); + notifyCustom(tr("Template created "), "ID: " + response.VMTEMPLATE.ID, false) + }, + error: onError }, "Template.create_dialog" : { @@ -367,7 +371,14 @@ var template_actions = { "Template.show_to_update" : { type: "single", call: OpenNebula.Template.show, - callback: fillTemplatePopUp, + callback: function(request, response) { + template_to_update_id = response.VMTEMPLATE.ID; + + fillTemplatePopUp( + response.VMTEMPLATE.TEMPLATE, + $create_template_dialog); + popUpUpdateTemplateDialog(); + }, error: onError }, @@ -391,7 +402,8 @@ var template_actions = { "Template.update" : { type: "single", call: OpenNebula.Template.update, - callback: function() { + callback: function(request, response){ + $create_template_dialog.trigger("reveal:close") notifyMessage(tr("Template updated correctly")); }, error: onError @@ -2065,1805 +2077,1071 @@ function addSectionJSON(template_json,context){ }); }; -// Prepare the template creation dialog -function setupCreateTemplateDialog(){ - //Helper functions for the dialog operations - - //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){ - var man_items = "."+man_class; - - //find enabled mandatory items in this context - man_items = $(man_items+' input:visible, '+man_items+' select:visible',context); - var r = true; - - //we fail it the item is enabled and has no value - $.each(man_items,function(){ - var item = $(this); - if (item.parents(".vm_param").attr('disabled') || - !(item.val().length)) { - r = false; - return false; - }; - }); - return r; - }; - - //Adds an option element to a multiple select box. Before doing so, - //it checks that the desired filter is passed - var box_add_element = function(context,box_tag,filter){ - var value=""; - var params= $('.vm_param',context); - var inputs= $('input:enabled',params); - var selects = $('select:enabled',params); - var fields = $.merge(inputs,selects); - - //are fields passing the filter? - var result = filter(); - if (!result) { - notifyError(tr("There are mandatory parameters missing in this section")); - return false; - } - - value={}; - - //With each enabled field we form a JSON object - var id = null; - $.each(fields,function(){ - var field = $(this); - if (!(field.parents(".vm_param").attr('disabled')) && - field.val().length){ - //Pick up parents ID if we do not have one - id = field.attr('id').length ? field.attr('id') : field.parent().attr('id'); - value[id] = field.val(); - }; - }); - var value_string = JSON.stringify(value); - var option= - ''; - $('select'+box_tag,context).append(option); - return false; - }; - - //Removes selected elements from a multiple select box - var box_remove_element = function(section_tag,box_tag){ - var context = $(section_tag,dialog); - $('select'+box_tag+' :selected',context).remove(); - return false; - }; - - // Given a section (context) and a tag for - // a multiple select in that section, it adds the - // JSON values to an array parsed as objects. - // Returns the array - var addBoxJSON = function(context,box_tag){ - var array = []; - $('select'+box_tag+' option',context).each(function(){ - array.push( JSON.parse($(this).val()) ); - }); - return array; - } - - //Given an object, removes those elements which are empty - //Used to clean up a template JSON before submitting - //it to opennebula.js - var removeEmptyObjects = function(obj){ - for (elem in obj){ - var remove = false; - var value = obj[elem]; - if (value instanceof Array) - { - if (value.length == 0) - remove = true; - else if (value.length > 0) - { - value = jQuery.grep(value, function (n) { - var obj_length = 0; - for (e in n) - obj_length += 1; - - if (obj_length == 0) - return false; - - return true; - }); - - if (value.length == 0) - remove = true; - } - } - else if (value instanceof Object) +//Given an object, removes those elements which are empty +//Used to clean up a template JSON before submitting +//it to opennebula.js +function removeEmptyObjects(obj){ + for (elem in obj){ + var remove = false; + var value = obj[elem]; + if (value instanceof Array) + { + if (value.length == 0) + remove = true; + else if (value.length > 0) { + value = jQuery.grep(value, function (n) { var obj_length = 0; - for (e in value) + for (e in n) obj_length += 1; + if (obj_length == 0) - remove = true; - } - else - { - value = String(value); - if (value.length == 0) - remove = true; - } + return false; - if (remove) - delete obj[elem]; + return true; + }); + + if (value.length == 0) + remove = true; + } } - return obj; + else if (value instanceof Object) + { + var obj_length = 0; + for (e in value) + obj_length += 1; + if (obj_length == 0) + remove = true; + } + else + { + value = String(value); + if (value.length == 0) + remove = true; + } + + if (remove) + delete obj[elem]; } + return obj; +} - //Toggles the icon when a section is folded/unfolded - var iconToggle = function(){ - $('.icon_left',$create_template_dialog).click(function(e){ - if ($('span',e.currentTarget).hasClass("ui-icon-plus")){ - $('span',e.currentTarget).removeClass("ui-icon-plus"); - $('span',e.currentTarget).addClass("ui-icon-minus"); - } else { - $('span',e.currentTarget).removeClass("ui-icon-minus"); - $('span',e.currentTarget).addClass("ui-icon-plus"); - }; - }); - }; +/************************************************************************** + CAPACITY TAB - //Fold/unfold all sections button - var foldUnfoldToggle = function() { - $('#fold_unfold_vm_params',$create_template_dialog).toggle( - function(){ - $('.vm_section fieldset',$create_template_dialog).show(); - $('.icon_left span',$create_template_dialog).removeClass("ui-icon-plus"); - $('.icon_left span',$create_template_dialog).addClass("ui-icon-minus"); - return false; - }, - function(){ - $('.vm_section fieldset',$create_template_dialog).hide(); - //Show capacity opts - $('.vm_section fieldset',$create_template_dialog).first().show(); - $('.icon_left span',$create_template_dialog).removeClass("ui-icon-minus"); - $('.icon_left span',$create_template_dialog).addClass("ui-icon-plus"); - return false; - }); - }; +**************************************************************************/ + +// Set ups the capacity section +function add_capacityTab(dialog){ + var html_tab_content = '
  • '+ + generate_capacity_tab_content() + + '
  • ' - /************************************************************************** - CAPACITY TAB + $("
    General
    ").appendTo($("dl#template_create_tabs", dialog)); + $(html_tab_content).appendTo($("ul#template_create_tabs_content", dialog)); - **************************************************************************/ + var capacity_section = $('li#capacityTab', dialog); + setup_capacity_tab_content(capacity_section); +} - // Set ups the capacity section - var add_capacityTab = function(){ - var html_tab_content = '
  • '+ - generate_capacity_tab_content() + - '
  • ' +/************************************************************************** + DISK TAB + +**************************************************************************/ - $("
    General
    ").appendTo($("dl#template_create_tabs")); - $(html_tab_content).appendTo($("ul#template_create_tabs_content")); - - var capacity_section = $('li#capacityTab', dialog); - setup_capacity_tab_content(capacity_section); - } - - /************************************************************************** - DISK TAB - - **************************************************************************/ - +function add_disks_tab(dialog) { var number_of_disks = 0; var disks_index = 0; - var add_disks_tab = function() { - var html_tab_content = '
  • '+ - '
    '+ - '
    '+ - '
    '+ - '
      '+ - '
    '+ - '
  • '; + var html_tab_content = '
  • '+ + '
    '+ + '
    '+ + '
    '+ + '
      '+ + '
    '+ + '
  • '; - $("
    "+tr("Storage")+"
    ").appendTo($("dl#template_create_tabs")); - $(html_tab_content).appendTo($("ul#template_create_tabs_content")); + $("
    "+tr("Storage")+"
    ").appendTo($("dl#template_create_tabs", dialog)); + $(html_tab_content).appendTo($("ul#template_create_tabs_content", dialog)); - // close icon: removing the tab on click - $( "#storageTab i.remove-tab" ).live( "click", function() { - var target = $(this).parent().attr("href"); - var dd = $(this).closest('dd'); - var dl = $(this).closest('dl'); - var content = $(target + 'Tab'); + // close icon: removing the tab on click + $( "#storageTab i.remove-tab", dialog ).live( "click", function() { + var target = $(this).parent().attr("href"); + var dd = $(this).closest('dd'); + var dl = $(this).closest('dl'); + var content = $(target + 'Tab'); - dd.remove(); - content.remove(); + dd.remove(); + content.remove(); - if (dd.attr("class") == 'active') { - dl.foundationTabs("set_tab", dl.children('dd').last()); - } + if (dd.attr("class") == 'active') { + dl.foundationTabs("set_tab", dl.children('dd').last()); + } - disks_index--; - }); + disks_index--; + }); - add_disk_tab(number_of_disks); + add_disk_tab(number_of_disks, dialog); + number_of_disks++; + disks_index++; - $("#tf_btn_disks").bind("click", function(){ - add_disk_tab(number_of_disks); - }); - } + $("#tf_btn_disks", dialog).bind("click", function(){ + add_disk_tab(number_of_disks, dialog); + number_of_disks++; + disks_index++; + }); +} - var add_disk_tab = function(disk_id) { - var str_disk_tab_id = 'disk' + disk_id; - var str_datatable_id = 'datatable_template_images' + disk_id; +// TODO dialog +function add_disk_tab(disk_id, dialog) { + var str_disk_tab_id = 'disk' + disk_id; + var str_datatable_id = 'datatable_template_images' + disk_id; - // Append the new div containing the tab and add the tab to the list - var html_tab_content = '
  • '+ - generate_disk_tab_content(str_disk_tab_id, str_datatable_id) + - '
  • ' - $(html_tab_content).appendTo($("ul#template_create_storage_tabs_content")); + // Append the new div containing the tab and add the tab to the list + var html_tab_content = '
  • '+ + generate_disk_tab_content(str_disk_tab_id, str_datatable_id) + + '
  • ' + $(html_tab_content).appendTo($("ul#template_create_storage_tabs_content", dialog)); - var a = $("
    \ - "+tr("DISK")+" \ -
    ").appendTo($("dl#template_create_storage_tabs")); + var a = $("
    \ + "+tr("DISK")+" \ +
    ").appendTo($("dl#template_create_storage_tabs", dialog)); - $(document).foundationTabs("set_tab", a); + $(document).foundationTabs("set_tab", a); - var disk_section = $('li#' +str_disk_tab_id+'Tab', dialog); - setup_disk_tab_content(disk_section, str_disk_tab_id, str_datatable_id) + var disk_section = $('li#' +str_disk_tab_id+'Tab', dialog); + setup_disk_tab_content(disk_section, str_disk_tab_id, str_datatable_id) +} - number_of_disks++; - disks_index++; - } +/************************************************************************** + NETWORK TAB - /************************************************************************** - NETWORK TAB +**************************************************************************/ - **************************************************************************/ +function add_nics_tab(dialog) { var number_of_nics = 0; var nics_index = 0; - var add_nics_tab = function() { - var html_tab_content = '
  • '+ - '
    '+ - '
    '+ + var html_tab_content = '
  • '+ + '
    '+ + '
    '+ + '
    '+ + '
      '+ + '
    '+ + '
  • '; + + $("
    "+tr("Network")+"
    ").appendTo($("dl#template_create_tabs", dialog)); + $(html_tab_content).appendTo($("ul#template_create_tabs_content", dialog)); + + // close icon: removing the tab on click + $( "#networkTab i.remove-tab" ).live( "click", function() { + var target = $(this).parent().attr("href"); + var dd = $(this).closest('dd'); + var dl = $(this).closest('dl'); + var content = $(target + 'Tab'); + + dd.remove(); + content.remove(); + + if (dd.attr("class") == 'active') { + dl.foundationTabs("set_tab", dl.children('dd').last()); + } + + nics_index--; + }); + + add_nic_tab(number_of_nics, dialog); + number_of_nics++; + nics_index++; + + $("#tf_btn_nics").bind("click", function(){ + add_nic_tab(number_of_nics, dialog); + number_of_nics++; + nics_index++; + }); +} + +function add_nic_tab(nic_id, dialog) { + var str_nic_tab_id = 'nic' + nic_id; + var str_datatable_id = 'datatable_template_networks' + nic_id; + + var html_tab_content = '
  • '+ + generate_nic_tab_content(str_nic_tab_id, str_datatable_id) + + '
  • ' + + // Append the new div containing the tab and add the tab to the list + var a = $("
    "+tr("NIC")+"
    ").appendTo($("dl#template_create_network_tabs", dialog)); + + $(html_tab_content).appendTo($("ul#template_create_network_tabs_content", dialog)); + + $(document).foundationTabs("set_tab", a); + + $('#nic_tab'+str_nic_tab_id, dialog).live('click', function(){ + $("#refresh_template_nic_table_button_class"+str_nic_tab_id).click(); + }); + + var nic_section = $('li#' + str_nic_tab_id + 'Tab', dialog); + setup_nic_tab_content(nic_section, str_nic_tab_id, str_datatable_id) +} + +/************************************************************************** + OS TAB + +**************************************************************************/ + +function add_osTab(dialog) { + var html_tab_content = '
  • '+ + ''+ + '
    '+ + '
    '+ + '
    '+tr("Boot")+'
    '+ + '
    '+tr("Kernel")+'
    '+ + '
    '+tr("Ramdisk")+'
    '+ + '
    '+tr("Features")+'
    '+ '
    '+ - '
      '+ - '
    '+ - '
  • '; - - $("
    "+tr("Network")+"
    ").appendTo($("dl#template_create_tabs")); - $(html_tab_content).appendTo($("ul#template_create_tabs_content")); - - // close icon: removing the tab on click - $( "#networkTab i.remove-tab" ).live( "click", function() { - var target = $(this).parent().attr("href"); - var dd = $(this).closest('dd'); - var dl = $(this).closest('dl'); - var content = $(target + 'Tab'); - - dd.remove(); - content.remove(); - - if (dd.attr("class") == 'active') { - dl.foundationTabs("set_tab", dl.children('dd').last()); - } - - disks_index--; - }); - - add_nic_tab(); - - $("#tf_btn_nics").bind("click", function(){ - add_nic_tab(); - }); - } - - var add_nic_tab = function() { - var str_nic_tab_id = 'nic' + number_of_nics; - var str_datatable_id = 'datatable_template_networks' + number_of_nics; - - var html_tab_content = '
  • '+ - generate_nic_tab_content(str_nic_tab_id, str_datatable_id) + - '
  • ' - - // Append the new div containing the tab and add the tab to the list - var a = $("
    "+tr("NIC")+"
    ").appendTo($("dl#template_create_network_tabs")); - - $(html_tab_content).appendTo($("ul#template_create_network_tabs_content")); - - $(document).foundationTabs("set_tab", a); - - $('#nic_tab'+str_nic_tab_id).live('click', function(){ - $("#refresh_template_nic_table_button_class"+str_nic_tab_id).click(); - }); - - var nic_section = $('li#' + str_nic_tab_id + 'Tab', dialog); - setup_nic_tab_content(nic_section, str_nic_tab_id, str_datatable_id) - - number_of_nics++; - nics_index++; - } - - /************************************************************************** - OS TAB - - **************************************************************************/ - - var add_osTab = function() { - var html_tab_content = '
  • '+ - ''+ - '
    '+ - '
    '+ - '
    '+tr("Boot")+'
    '+ - '
    '+tr("Kernel")+'
    '+ - '
    '+tr("Ramdisk")+'
    '+ - '
    '+tr("Features")+'
    '+ - '
    '+ - '
      '+ - '
    • '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("CPU architecture to virtualization")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Boot device type")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Device to be mounted as root")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Arguments for the booting kernel")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Path to the bootloader executable")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Set the OS of the VM, only for VMware")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
    • '+ - '
    • '+ - '
      '+ - '
      '+ - ' '+tr("Registered Image")+ - '
      '+ - '
      '+ - ' '+tr("Remote PATH")+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      ' + - '' + - '
      ' + - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
      '+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Datastore")+''+tr("Size")+''+tr("Type")+''+tr("Registration time")+''+tr("Persistent")+''+tr("Status")+''+tr("#VMS")+''+tr("Target")+'
      '+ - '
      '+ - ''+tr("Please select a Kernel from the list")+''+ - ''+ - ''+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
    • '+ - '
    • '+ - '
      '+ - '
      '+ - ' '+tr("Registered Image ") + - '
      '+ - '
      '+ - ' '+tr("Remote PATH")+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      ' + - '' + - '
      ' + - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
      '+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Datastore")+''+tr("Size")+''+tr("Type")+''+tr("Registration time")+''+tr("Persistent")+''+tr("Status")+''+tr("#VMS")+''+tr("Target")+'
      '+ - '
      '+ - ''+tr("Please select a Ramdisk from the list")+''+ - ''+ - ''+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
    • '+ - '
    • '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Add support in the VM for Advanced Configuration and Power Interface (ACPI)")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Add support in the VM for Physical Address Extension (PAE)")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr(" Adds a PCI Controller that provides bridge-to-bridge capability, only for VMware.")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
    • '+ - '
    '+ - '
    '+ - ''+ - '
  • ' - - $("
    OS Booting
    ").appendTo($("dl#template_create_tabs")); - $(html_tab_content).appendTo($("ul#template_create_tabs_content")); - - var os_section = $('li#osTab', dialog); - var kernel_section = $('li#kernelTab', os_section); - var initrd_section = $('li#ramdiskTab', os_section); - - - // Select Image or Volatile disk. The div is hidden depending on the selection, and the - // vm_param class is included to be computed when the template is generated. - $("input[name='kernel_type']").change(function(){ - if ($("input[name='kernel_type']:checked").val() == "kernel_ds") { - $("div.kernel_ds", os_section).toggle(); - $("div#kernel_ds_inputs", os_section).addClass('vm_param'); - $("div.kernel_path", os_section).hide(); - $("div#kernel_path_inputs", os_section).removeClass('vm_param'); - } - else { - $("div.kernel_ds", os_section).hide(); - $("div#kernel_ds_inputs", os_section).removeClass('vm_param'); - $("div.kernel_path", os_section).toggle(); - $("div#kernel_path_inputs", os_section).addClass('vm_param'); - } - }); - - $("input[name='initrd_type']").change(function(){ - if ($("input[name='initrd_type']:checked").val() == "initrd_ds") { - $("div.initrd_ds", os_section).toggle(); - $("div#initrd_ds_inputs", os_section).addClass('vm_param'); - $("div.initrd_path", os_section).hide(); - $("div#initrd_path_inputs", os_section).removeClass('vm_param'); - } - else { - $("div.initrd_ds", os_section).hide(); - $("div#initrd_ds_inputs", os_section).removeClass('vm_param'); - $("div.initrd_path", os_section).toggle(); - $("div#initrd_path_inputs", os_section).addClass('vm_param'); - } - }); - - var dataTable_template_kernel = $('#datatable_kernel', dialog).dataTable({ - "bAutoWidth":false, - "sDom" : '<"H">t<"F"p>', - "iDisplayLength": 4, - "aoColumnDefs": [ - { "sWidth": "35px", "aTargets": [0,1] }, - { "bVisible": false, "aTargets": [3,2,5,6,7,9,8,11,12,10]} - ], - //"fnDrawCallback": function(oSettings) { - // var nodes = this.fnGetNodes(); - // $.each(nodes, function(){ - // if ($(this).find("td:eq(1)").html() == $('#KERNEL', kernel_section).text()) { - // $("td", this).addClass('markrow'); - // $('input.check_item', this).attr('checked','checked'); - // } - // }) - //}, - "fnInitComplete": function(oSettings) { - this.fnFilter("KERNEL", 7) - } - }); - - $("#refresh_kernel_table").die(); - $("#refresh_kernel_table").live('click', function(){ - update_datatable_template_files(dataTable_template_kernel) - }); - - // Retrieve the images to fill the datatable - update_datatable_template_files(dataTable_template_kernel); - - $('#kernel_search', dialog).keyup(function(){ - dataTable_template_kernel.fnFilter( $(this).val() ); - }) - - dataTable_template_kernel.fnSort( [ [1,config['user_config']['table_order']] ] ); - - $('#datatable_kernel tbody', dialog).delegate("tr", "click", function(e){ - var aData = dataTable_template_kernel.fnGetData(this); - - $("td.markrowchecked", kernel_section).removeClass('markrowchecked'); - $('tbody input.check_item', kernel_section).removeAttr('checked'); - - $('#image_selected', kernel_section).show(); - $('#select_image', kernel_section).hide(); - $('.alert-box', kernel_section).hide(); - - $("td", this).addClass('markrowchecked'); - $('input.check_item', this).attr('checked','checked'); - - $('#KERNEL', kernel_section).text(aData[4]); - $('#KERNEL_DS', kernel_section).val("$FILE[IMAGE_ID="+ aData[1] +"]"); - return true; - }); - - - var datTable_template_initrd = $('#datatable_initrd', dialog).dataTable({ - "bAutoWidth":false, - "iDisplayLength": 4, - "sDom" : '<"H">t<"F"p>', - "aoColumnDefs": [ - { "sWidth": "35px", "aTargets": [0,1] }, - { "bVisible": false, "aTargets": [2,3,5,6,7,9,8,10,11,12]} - ], - "fnInitComplete": function(oSettings) { - this.fnFilter("RAMDISK", 7) - // var nodes = this.fnGetNodes(); - // $.each(nodes, function(){ - // if ($(this).find("td:eq(1)").html() == $('#INITRD', kernel_section).text()) { - // $("td", this).addClass('markrowchecked'); - // $('input.check_item', this).attr('checked','checked'); - // } - // }) - } - }); - - - - $("#refresh_ramdisk_table").die(); - $("#refresh_ramdisk_table").live('click', function(){ - update_datatable_template_files(datTable_template_initrd) - }); - - update_datatable_template_files(datTable_template_initrd); - - $('#initrd_search', dialog).keyup(function(){ - datTable_template_initrd.fnFilter( $(this).val() ); - }) - - datTable_template_initrd.fnSort( [ [1,config['user_config']['table_order']] ] ); - - $('#datatable_initrd tbody', dialog).delegate("tr", "click", function(e){ - var aData = datTable_template_initrd.fnGetData(this); - - $("td.markrowchecked", initrd_section).removeClass('markrowchecked'); - $('tbody input.check_item', initrd_section).removeAttr('checked'); - - $('#image_selected', initrd_section).show(); - $('#select_image', initrd_section).hide(); - $('.alert-box', initrd_section).hide(); - - $("td", this).addClass('markrowchecked'); - $('input.check_item', this).attr('checked','checked'); - - $('#INITRD', os_section).text(aData[4]); - $('#INITRD_DS', os_section).val("$FILE[IMAGE_ID="+ aData[1] +"]"); - return true; - }); - - // Hide image advanced options - $('fieldset.advanced', $('div#advanced_os')).hide(); - - $('#advanced_os', dialog).click(function(){ - $('fieldset.advanced', $('div##advanced_os')).toggle(); - return false; - }); - } - - - /************************************************************************** - INPUT/OUTPUT TAB - - **************************************************************************/ - - var add_ioTab = function() { - var html_tab_content = '
  • '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+tr("Graphics")+''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ' VNC '+ - '
    '+ - '
    '+ - ' SDL'+ - '
    '+ - '
    '+ - ' SPICE'+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+tr("IP to listen on")+'
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+tr("Port for the VNC/SPICE server")+'
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+tr("Password for the VNC/SPICE server")+'
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+tr("Keyboard configuration locale to use in the VNC/SPICE display")+'
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+tr("Inputs")+''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
    '+tr("TYPE")+''+tr("BUS")+'
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
  • ' - - - $("
    Input/Output
    ").appendTo($("dl#template_create_tabs")); - $(html_tab_content).appendTo($("ul#template_create_tabs_content")); - - $("input[name='graphics_type']").change(function(){ - $("#TYPE", $('li#ioTab .graphics')).val($(this).attr("value")) - $("#LISTEN", $('li#ioTab')).val("0.0.0.0") - }); - - $('#add_input', $('li#ioTab')).click(function() { - var table = $('#input_table', $('li#ioTab'))[0]; - var rowCount = table.rows.length; - var row = table.insertRow(-1); - $(row).addClass("vm_param"); - - var cell1 = row.insertCell(0); - var element1 = document.createElement("input"); - element1.id = "TYPE" - element1.type = "text"; - element1.value = $('select#TYPE', $('li#ioTab')).val() - cell1.appendChild(element1); - - var cell2 = row.insertCell(1); - var element2 = document.createElement("input"); - element2.id = "BUS" - element2.type = "text"; - element2.value = $('select#BUS', $('li#ioTab')).val() - cell2.appendChild(element2); - - - var cell3 = row.insertCell(2); - cell3.innerHTML = ""; - }); - - $( "#ioTab i.remove-tab" ).live( "click", function() { - $(this).closest("tr").remove() - }); - } - - /************************************************************************** - CONTEXT TAB - - **************************************************************************/ - - var add_contextTab = function() { - var html_tab_content = '
  • '+ - '
    '+ - '
    '+ - '
    '+tr("Network & SSH")+'
    '+ - '
    '+tr("Files")+'
    '+ - '
    '+tr("Custom variables")+'
    '+ - '
    '+ - '
      '+ - '
    • '+ - '
      '+ - '
      '+ - '
      '+ - ''+tr("SSH")+''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+tr("Add an ssh public key to the context. If the Public Key textarea is empty then the user variable SSH_PUBLIC_KEY will be used.")+'
      '+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - ''+ - '
      '+ - '
      '+ - '
      '+ - '
      '+ - '