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

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

This commit is contained in:
Hector Sanjuan 2012-02-02 11:02:54 +01:00
parent f9b9f1a0cd
commit 76506b5737
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}"