diff --git a/src/cli/one_helper/onetemplate_helper.rb b/src/cli/one_helper/onetemplate_helper.rb index 425e25d2d3..1a4fdb753f 100644 --- a/src/cli/one_helper/onetemplate_helper.rb +++ b/src/cli/one_helper/onetemplate_helper.rb @@ -23,7 +23,7 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper :format => String, :description => <<-EOT.strip Name of the new VM or TEMPLATE. When instantiating - multiple VMs you can use the\"%i\" wildcard to produce + multiple VMs you can use the \"%i\" wildcard to produce different names such as vm-0, vm-1... EOT } diff --git a/src/cli/onetemplate b/src/cli/onetemplate index 6ca92950b2..ed360ecfa0 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -172,7 +172,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do managed with the 'onevm' command EOT - command :instantiate, instantiate_desc, :templateid, + command :instantiate, instantiate_desc, :templateid, [:file, nil], :options=>instantiate_options do exit_code=0 @@ -184,7 +184,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do on_hold = options[:hold] != nil - res = t.instantiate(name, on_hold) + extra_template = "" + if !args[1].nil? + extra_template = File.read(args[1]) + end + + res = t.instantiate(name, on_hold, extra_template) if !OpenNebula.is_error?(res) puts "VM ID: #{res}" diff --git a/src/oca/ruby/opennebula/template.rb b/src/oca/ruby/opennebula/template.rb index e626ce5460..8b73248cb3 100644 --- a/src/oca/ruby/opennebula/template.rb +++ b/src/oca/ruby/opennebula/template.rb @@ -90,14 +90,19 @@ module OpenNebula # string OpenNebula will set a default name # @param hold [true,false] false to create the VM in pending state, # true to create it on hold + # @param template [String] User provided Template to merge with the + # one being instantiated # # @return [Integer, OpenNebula::Error] The new VM id, Error # otherwise - def instantiate(name="", hold=false) + def instantiate(name="", hold=false, template="") return Error.new('ID not defined') if !@pe_id name ||= "" - rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id, name, hold) + template ||= "" + + rc = @client.call( + TEMPLATE_METHODS[:instantiate], @pe_id, name, hold, template) return rc end