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

feature #577: added -m switch to onevm create to specify the number of VMs

This commit is contained in:
Javi Fontan 2011-07-05 18:48:37 +02:00
parent ae03441edc
commit 58301a249c
2 changed files with 23 additions and 4 deletions

View File

@ -17,6 +17,14 @@
require 'one_helper'
class OneVMHelper < OpenNebulaHelper::OneHelper
MULTIPLE={
:name => "multiple",
:short => "-m x",
:large => "--multiple x",
:format => Integer,
:description => "Instance multiple VMs"
}
def self.rname
"VM"
end

View File

@ -78,11 +78,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do
See 'onetemplate create' and 'onetemplate instantiate'
EOT
command :create, create_desc, :file do
helper.create_resource(options) do |vm|
template=File.read(args[0])
vm.allocate(template)
command :create, create_desc, :file,
:options=>[OneVMHelper::MULTIPLE]+OpenNebulaHelper::OPTIONS do
number = options[:multiple] || 1
exit_code=nil
number.times do
exit_code=helper.create_resource(options) do |vm|
template=File.read(args[0])
error=vm.allocate(template)
end
break if exit_code==-1
end
exit_code
end
delete_desc = <<-EOT.unindent