class MotherBrain::Command
Attributes
plugin[R]
@return [MB::Plugin]
scope[R]
@return [MB::Plugin, MB::Component]
type[R]
@return [Symbol]
Public Class Methods
new(name, scope, &block)
click to toggle source
@param [#to_s] name @param [MB::Plugin, MB::Component] scope
# File lib/mb/command.rb, line 27 def initialize(name, scope, &block) set_attribute(:name, name.to_s) @scope = scope case @scope when MB::Plugin @plugin = @scope @type = :plugin when MB::Component @plugin = @scope.plugin @type = :component else raise RuntimeError, "no matching command type for the given scope: #{scope}." end if block_given? dsl_eval(&block) end end
Public Instance Methods
description()
click to toggle source
@return [String]
# File lib/mb/command.rb, line 48 def description _attributes_.description || "run #{name} command on #{scope.name}" end
id()
click to toggle source
@return [Symbol]
# File lib/mb/command.rb, line 53 def id self.name.to_sym end
invoke(job, environment, node_filter, *args)
click to toggle source
Run the command on the given environment
@param [MB::Job] job
a job to update with progress
@param [String] environment
the environment to invoke the command on
@param [Array] node_filter
list of nodes to limit the command to
@param [Array] args
additional arguments to pass to the command
@raise [MB::ChefConnectionError] if there was an error communicating to the Chef
Server
# File lib/mb/command.rb, line 69 def invoke(job, environment, node_filter, *args) CommandRunner.new(job, environment, scope, execute, node_filter, *args) end
Private Instance Methods
dsl_eval(&block)
click to toggle source
# File lib/mb/command.rb, line 75 def dsl_eval(&block) CleanRoom.new(self).instance_eval(&block) end