From cb070444c7ca7be4742b4f77808bee935df65f16 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 5 Sep 2013 17:42:55 +0200 Subject: [PATCH 1/4] feature #2187: add files_ds and init options to CLI template creation --- src/cli/one_helper.rb | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index be3e96dc01..7c91853407 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -248,6 +248,19 @@ EOT :large => '--boot device', :description => 'Select boot device (hd|fd|cdrom|network)', :format => String + }, + { + :name => 'files_ds', + :large => '--files_ds file1,file2', + :format => Array, + :description => 'Add files to the contextualization CD from the' << + 'files datastore' + }, + { + :name => 'init', + :large => '--init script1,script2', + :format => Array, + :description => 'Script or scripts to start in context' } ] @@ -774,7 +787,8 @@ EOT end def self.create_context(options) - if !(options.keys & [:ssh, :net_context, :context]).empty? + context_options = [:ssh, :net_context, :context, :init, :files_ds] + if !(options.keys & context_options).empty? lines=[] if options[:ssh] @@ -792,11 +806,21 @@ EOT end if options[:net_context] - lines << "NETWORK = \"YES\"" + lines << "NETWORK = \"YES\"" end lines+=options[:context] if options[:context] + if options[:files_ds] + options[:files_ds].each do |file| + lines << %Q + end + end + + if options[:init] + lines << %Q + end + if !lines.empty? "CONTEXT=[\n"< Date: Fri, 6 Sep 2013 16:20:16 +0200 Subject: [PATCH 2/4] feature #2187: change separator of INIT_SCRIPTS to space --- src/cli/one_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 7c91853407..d73d6fbe1c 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -818,7 +818,7 @@ EOT end if options[:init] - lines << %Q + lines << %Q end if !lines.empty? From 4d95677c48950235ebd8004acf8892bc48ce9824 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 6 Sep 2013 16:40:26 +0200 Subject: [PATCH 3/4] feature #2187: fix FILES_DS generation from CLI --- src/cli/one_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index d73d6fbe1c..d153dc70b9 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -812,9 +812,13 @@ EOT lines+=options[:context] if options[:context] if options[:files_ds] - options[:files_ds].each do |file| - lines << %Q - end + text='FILES_DS="' + text << options[:files_ds].map do |file| + %Q<$FILE[IMAGE=\\"#{file}\\"]> + end.join(' ') + text << '"' + + lines << text end if options[:init] From 59a5bc8d63e25dabddc1879908c8ee0ae8268fb3 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 6 Sep 2013 16:59:29 +0200 Subject: [PATCH 4/4] feature #2187: Add INIT_SCRIPTS to Sunstone --- .../public/js/plugins/templates-tab.js | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index da15d5219c..efb08601e0 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -2865,7 +2865,7 @@ function setupCreateTemplateDialog(){ } }); - + $("#refresh_ramdisk_table").die(); $("#refresh_ramdisk_table").live('click', function(){ @@ -3178,16 +3178,27 @@ function setupCreateTemplateDialog(){ ''+ '
'+ '
'+ - '
'+ + '
'+ ''+ '
'+ - '
'+ + '
'+ ''+ '
'+ - '
'+ + '
'+ '
'+ '
'+ '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+tr("If the VM uses the OpenNebula contextualization package the init.sh file is executed by default. When the init script added is not called init.sh or more than one init script is added, this list contains the scripts to run and the order. Ex. “init.sh users.sh mysql.sh”")+'
'+ + '
'+ + '
'+ ''+ '
  • '+ '
    '+ @@ -3287,7 +3298,7 @@ function setupCreateTemplateDialog(){ } }); - + $("#refresh_context_table").die(); $("#refresh_context_table").live('click', function(){ @@ -4601,6 +4612,9 @@ function fillTemplatePopUp(request, response){ else if (net_regexp.test(key)) { $("#network_context", context_section).attr('checked','checked'); } + else if ("INIT_SCRIPTS" == key){ + $("input#INIT_SCRIPTS").val(value); + } else if ("FILES_DS" == key){ $('#FILES_DS', context_section).val(context["FILES_DS"]) var files = []; @@ -5034,7 +5048,7 @@ function setupInstantiateTemplateDialog(easy_provision){ dialog.addClass("reveal-modal large"); dialog.removeClass("max-height") } - + setupTips(dialog); @@ -5071,7 +5085,7 @@ function setupInstantiateTemplateDialog(easy_provision){ 'image_id': image_id } } - } + } if (!vm_name.length){ //empty name use OpenNebula core default for (var i=0; i< n_times_int; i++){