diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 8857c889c7..ba149d6a31 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -572,4 +572,16 @@ EOT [0, template] end + + def self.create_template_options_used?(options) + # Get the template options names as symbols. options hash + # uses symbols + template_options=OpenNebulaHelper::TEMPLATE_OPTIONS.map do |o| + o[:name].to_sym + end + + # Check if one at least one of the template options is + # in options hash + (template_options-options.keys)!=template_options + end end diff --git a/src/cli/onetemplate b/src/cli/onetemplate index cccd4b3d77..e2f24d8537 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -86,6 +86,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do :options=>OpenNebulaHelper::TEMPLATE_OPTIONS do res=OpenNebulaHelper.create_template(options) + if args[0] && OpenNebulaHelper.create_template_options_used?(options) + STDERR.puts "You can not use both template file and template"<< + " creation options." + next -1 + end + if res.first!=0 STDERR.puts res.last next -1 diff --git a/src/cli/onevm b/src/cli/onevm index c09d5971b3..ed6f95b070 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -114,6 +114,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do end if args[0] + if OpenNebulaHelper.create_template_options_used?(options) + STDERR.puts "You can not use both template file and template"<< + " creation options." + next -1 + end + begin template=File.read(args[0]) rescue