diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index be3e96dc01..d153dc70b9 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,25 @@ EOT end if options[:net_context] - lines << "NETWORK = \"YES\"" + lines << "NETWORK = \"YES\"" end lines+=options[:context] if options[:context] + if options[:files_ds] + text='FILES_DS="' + text << options[:files_ds].map do |file| + %Q<$FILE[IMAGE=\\"#{file}\\"]> + end.join(' ') + text << '"' + + lines << text + end + + if options[:init] + lines << %Q + end + if !lines.empty? "CONTEXT=[\n"<'+ '
'+ '
'+ - '
'+ + '
'+ ''+ '
'+ - '
'+ + '
'+ ''+ '
'+ - '
'+ + '
'+ '
'+ '
'+ '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+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++){