1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

Feature : Add the new template instantiate param to ruby oca and cli

This commit is contained in:
Carlos Martín 2013-02-15 16:06:31 +01:00
parent 3deeec215a
commit 9280aa362b
3 changed files with 15 additions and 5 deletions
src
cli
oca/ruby/opennebula

@ -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
}

@ -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}"

@ -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