Class: MotherBrain::Gear::Service::Action Private
- Inherits:
-
Object
- Object
- MotherBrain::Gear::Service::Action
- Includes:
- MB::Mixin::Services
- Defined in:
- lib/mb/gears/service/action.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #name ⇒ String readonly private
Instance Method Summary collapse
-
#initialize(name, component, &block) ⇒ Action
constructor
private
A new instance of Action.
-
#run(job, environment, nodes, run_chef = true) ⇒ Service::Action
private
Run this action on the specified nodes.
Constructor Details
#initialize(name, component, &block) ⇒ Action
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Action.
15 16 17 18 19 20 21 22 23 |
# File 'lib/mb/gears/service/action.rb', line 15 def initialize(name, component, &block) unless block_given? raise ArgumentError, "block required for action '#{name}' on component '#{component.name}'" end @name = name @component = component @block = block end |
Instance Attribute Details
#name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/mb/gears/service/action.rb', line 9 def name @name end |
Instance Method Details
#run(job, environment, nodes, run_chef = true) ⇒ Service::Action
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run this action on the specified nodes.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mb/gears/service/action.rb', line 35 def run(job, environment, nodes, run_chef = true) job.set_status("Running component: #{component.name} service action: #{name} on #{nodes.collect(&:name).join(', ')}") runner = Service::ActionRunner.new(environment, nodes, &block) runner.run(job) if run_chef || runner.toggle_callbacks.any? node_querier.bulk_chef_run(job, nodes, runner.service_recipe) end self ensure runner.reset(job) end |