lib/cloudstack-cli/commands/stack.rb in cloudstack-cli-0.1.2 vs lib/cloudstack-cli/commands/stack.rb in cloudstack-cli-0.1.3

- old
+ new

@@ -1,24 +1,28 @@ class Stack < CloudstackCli::Base + include CloudstackCli::Helper desc "create STACKFILE", "create a stack of servers" def create(stackfile) stack = parse_stackfile(stackfile) - say "Crate stack #{stack["name"]}..." - puts + say "Create stack #{stack["name"]}..." + threads = [] stack["servers"].each do |server| - server["name"].split(', ').each do |name| - CloudstackCli::Helper.new(options[:config]).bootstrap_server( - name, - server["zone"] || stack['zone'], - server["template"], - server["offering"], - server["networks"] ? server["networks"].split(', ') : nil, - server["port_rules"] ? server["port_rules"].split(', ') : nil, - stack["project"] - ) + server["name"].split(', ').each_with_index do |name, i| + threads << Thread.new(i) { + bootstrap_server( + name, + server["zone"] || stack["zone"], + server["template"], + server["offering"], + server["networks"] ? server["networks"].split(', ') : nil, + server["port_rules"] ? server["port_rules"].split(', ') : nil, + stack["project"] + ) + } end end + threads.each {|t| t.join } end desc "destroy STACKFILE", "destroy a stack of servers" option :force, description: "destroy without asking", \ No newline at end of file