diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 46321ccb91..e1433bcd01 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -76,6 +76,12 @@ EOT :format => String } + DRY={ + :name => 'dry', + :large => '--dry', + :description => 'Just print the template' + } + CLIENT_OPTIONS=[ { :name => 'user', @@ -194,15 +200,10 @@ EOT :large => '--boot device', :description => 'Select boot device (hd|fd|cdrom|network)', :format => String - }, - { - :name => 'dry', - :large => '--dry', - :description => 'Just print the template' } ] - TEMPLATE_OPTIONS_VM=[TEMPLATE_NAME_VM]+TEMPLATE_OPTIONS + TEMPLATE_OPTIONS_VM=[TEMPLATE_NAME_VM]+TEMPLATE_OPTIONS+[DRY] OPTIONS = XML, NUMERIC, KILOBYTES diff --git a/src/cli/one_helper/oneimage_helper.rb b/src/cli/one_helper/oneimage_helper.rb index 6e1f796fc7..727413d855 100644 --- a/src/cli/one_helper/oneimage_helper.rb +++ b/src/cli/one_helper/oneimage_helper.rb @@ -161,7 +161,8 @@ class OneImageHelper < OpenNebulaHelper::OneHelper [0, o] end end - } + }, + OpenNebulaHelper::DRY ] def self.rname @@ -322,7 +323,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper end template=create_image_variables( - options, template_options-[:persistent]) + options, template_options-[:persistent, :dry]) template<<"PERSISTENT=YES\n" if options[:persistent] diff --git a/src/cli/oneimage b/src/cli/oneimage index df71c6a568..c414c4046d 100755 --- a/src/cli/oneimage +++ b/src/cli/oneimage @@ -107,7 +107,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, create_desc, [:file, nil], :options=>CREATE_OPTIONS + OneImageHelper::TEMPLATE_OPTIONS do - if options[:datastore].nil? + if options[:datastore].nil? && !options[:dry] STDERR.puts "Datastore to save the image is mandatory: " STDERR.puts "\t -d datastore_id" exit -1 @@ -134,6 +134,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do template = res.last end + if options[:dry] + puts template + exit 0 + end + image.allocate(template, options[:datastore]) rescue => e STDERR.puts e.messsage