1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #1030: add %i wildcard support to cli when instantiating multiple VMs.

(cherry picked from commit 76506b57377bc5d8ed4a798ac0ada1d8aad7dcb6)
This commit is contained in:
Hector Sanjuan 2012-02-02 11:02:54 +01:00 committed by Ruben S. Montero
parent cdb47d12c7
commit ab79e3bb41
2 changed files with 8 additions and 3 deletions

View File

@ -22,7 +22,11 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper
:short => "-n vm_name",
:large => "--name vm_name",
:format => String,
:description => "Name of the new Virtual Machine"
:description => <<-EOT
Name of the new Virtual Machine. When instantiating
multiple VMs you can use the\"%i\" wildcard to produce
different names such as vm-0, vm-1...
EOT
}
MULTIPLE={

View File

@ -108,9 +108,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
exit_code=0
number = options[:multiple] || 1
number.times do
number.times do |i|
exit_code=helper.perform_action(args[0],options,"instantiated") do |t|
res = t.instantiate(options[:vm_name])
name = options[:vm_name].gsub("%i",i.to_s)
res = t.instantiate(name)
if !OpenNebula.is_error?(res)
puts "VM ID: #{res}"