Module: Kitchen::Command::RunAction
Overview
Common module to execute a Kitchen action such as create, converge, etc.
Instance Method Summary collapse
-
#run_action(action, instances, *args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of instances.
Instance Method Details
#run_action(action, instances, *args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of instances. The instance actions will take place in a seperate thread of execution which may or may not be running concurrently.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/kitchen/command.rb', line 161 def run_action(action, instances, *args) concurrency = 1 if [:concurrency] concurrency = [:concurrency] || instances.size concurrency = instances.size if concurrency > instances.size end queue = Queue.new instances.each { |i| queue << i } concurrency.times { queue << nil } threads = [] concurrency.times do threads << Thread.new do while instance = queue.pop instance.public_send(action, *args) end end end threads.map(&:join) end |