mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Bug #733: New options for onetemplate instantiate; name of the new VM and instance multiple VMs
This commit is contained in:
parent
c2ea27f198
commit
7d016df19b
@ -17,6 +17,22 @@
|
||||
require 'one_helper'
|
||||
|
||||
class OneTemplateHelper < OpenNebulaHelper::OneHelper
|
||||
VM_NAME={
|
||||
:name => "vm_name",
|
||||
:short => "-n vm_name",
|
||||
:large => "--name vm_name",
|
||||
:format => String,
|
||||
:description => "Name of the new Virtual Machine"
|
||||
}
|
||||
|
||||
MULTIPLE={
|
||||
:name => "multiple",
|
||||
:short => "-m x",
|
||||
:large => "--multiple x",
|
||||
:format => Integer,
|
||||
:description => "Instance multiple VMs"
|
||||
}
|
||||
|
||||
def self.rname
|
||||
"VMTEMPLATE"
|
||||
end
|
||||
|
@ -40,11 +40,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
# Global Options
|
||||
########################################################################
|
||||
set :option, CommandParser::OPTIONS
|
||||
|
||||
|
||||
list_options = CLIHelper::OPTIONS
|
||||
list_options << OpenNebulaHelper::XML
|
||||
list_options << OpenNebulaHelper::NUMERIC
|
||||
|
||||
instantiate_options = [
|
||||
OneTemplateHelper::VM_NAME,
|
||||
OneTemplateHelper::MULTIPLE
|
||||
]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
@ -98,16 +103,26 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
managed with the 'onevm' command
|
||||
EOT
|
||||
|
||||
command :instantiate, instantiate_desc, [:range,:templateid_list] do
|
||||
helper.perform_actions(args[0],options,"instantiated") do |t|
|
||||
res = t.instantiate
|
||||
command :instantiate, instantiate_desc, :templateid,
|
||||
:options=>instantiate_options do
|
||||
exit_code=0
|
||||
|
||||
if !OpenNebula.is_error?(res)
|
||||
puts "VM ID: #{res}"
|
||||
number = options[:multiple] || 1
|
||||
number.times do
|
||||
exit_code=helper.perform_action(args[0],options,"instantiated") do |t|
|
||||
res = t.instantiate(options[:vm_name])
|
||||
|
||||
if !OpenNebula.is_error?(res)
|
||||
puts "VM ID: #{res}"
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
res
|
||||
break if exit_code==-1
|
||||
end
|
||||
|
||||
exit_code
|
||||
end
|
||||
|
||||
publish_desc = <<-EOT.unindent
|
||||
|
@ -60,7 +60,7 @@ module OpenNebula
|
||||
# ---------------------------------------------------------------------
|
||||
# XML-RPC Methods for the Template Object
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
# Retrieves the information of the given Template.
|
||||
def info()
|
||||
super(TEMPLATE_METHODS[:info], 'VMTEMPLATE')
|
||||
@ -85,6 +85,7 @@ module OpenNebula
|
||||
def instantiate(name="")
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
name ||= ""
|
||||
rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id, name)
|
||||
|
||||
return rc
|
||||
|
Loading…
x
Reference in New Issue
Block a user