Class: MotherBrain::CommandInvoker::Worker
- Inherits:
-
Object
- Object
- MotherBrain::CommandInvoker::Worker
- Includes:
- Celluloid
- Defined in:
- lib/mb/command_invoker/worker.rb
Instance Attribute Summary collapse
- #command ⇒ MB::Command readonly
- #environment ⇒ String readonly
- #node_filter ⇒ Array readonly
Instance Method Summary collapse
-
#initialize(command, environment, node_filter = nil) ⇒ Worker
constructor
A new instance of Worker.
- #run(job, arguments = Array.new) ⇒ Object
Constructor Details
#initialize(command, environment, node_filter = nil) ⇒ Worker
Returns a new instance of Worker.
19 20 21 22 23 |
# File 'lib/mb/command_invoker/worker.rb', line 19 def initialize(command, environment, node_filter = nil) @command = command @environment = environment @node_filter = node_filter end |
Instance Attribute Details
#command ⇒ MB::Command (readonly)
7 8 9 |
# File 'lib/mb/command_invoker/worker.rb', line 7 def command @command end |
#environment ⇒ String (readonly)
9 10 11 |
# File 'lib/mb/command_invoker/worker.rb', line 9 def environment @environment end |
#node_filter ⇒ Array (readonly)
11 12 13 |
# File 'lib/mb/command_invoker/worker.rb', line 11 def node_filter @node_filter end |
Instance Method Details
#run(job, arguments = Array.new) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mb/command_invoker/worker.rb', line 27 def run(job, arguments = Array.new) arguments ||= Array.new msg = "Invoking #{command.type} command #{command.scope.name} #{command.name} on #{environment}" msg << " with arguments: #{arguments}" if arguments.any? job.set_status(msg) command.invoke(job, environment, node_filter, *arguments) rescue RemoteCommandError => ex abort(ex) end |