From 1d41973de3ce3e80902dba2027c2f818894e780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 15 Feb 2013 16:53:15 +0100 Subject: [PATCH] Feature #1697: Add VM creation options to onetemplate instantiate (--cpu, --memory...) --- src/cli/onetemplate | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/cli/onetemplate b/src/cli/onetemplate index ed360ecfa0..390cdd61fa 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -173,9 +173,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :instantiate, instantiate_desc, :templateid, [:file, nil], - :options=>instantiate_options do + :options=>instantiate_options+OpenNebulaHelper::TEMPLATE_OPTIONS do exit_code=0 + if args[1] && OpenNebulaHelper.create_template_options_used?(options) + STDERR.puts "You cannot use both template file and template"<< + " creation options." + next -1 + end + number = options[:multiple] || 1 number.times do |i| exit_code=helper.perform_action(args[0],options,"instantiated") do |t| @@ -185,8 +191,18 @@ cmd=CommandParser::CmdParser.new(ARGV) do on_hold = options[:hold] != nil extra_template = "" - if !args[1].nil? + + if args[1] extra_template = File.read(args[1]) + else + res = OpenNebulaHelper.create_template(options) + + if res.first != 0 + STDERR.puts res.last + next -1 + end + + extra_template = res.last end res = t.instantiate(name, on_hold, extra_template)