Class: Nucleon::Action::Node::Exec

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleon/action/node/exec.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.describeObject


Info



10
11
12
# File 'lib/nucleon/action/node/exec.rb', line 10

def self.describe
  super(:node, :exec, 605)
end

Instance Method Details

#argumentsObject




25
26
27
# File 'lib/nucleon/action/node/exec.rb', line 25

def arguments
  [ :command ]
end

#configureObject


Settings



17
18
19
20
21
# File 'lib/nucleon/action/node/exec.rb', line 17

def configure
  super do
    register :command, :array, nil
  end
end

#executeObject


Operations



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nucleon/action/node/exec.rb', line 32

def execute
  super do |node|
    if settings[:command].length > 1
      settings[:command].collect! do |value|
        if value.strip.match(/\s+/)
          value = "\"#{value}\""
        end
        value
      end
    end
    command_str = settings[:command].join(' ')

    if node
      result = node.exec({ :commands => [ command_str ] }).first
    else
      result = CORL.cli_run(command_str)
    end
    myself.status = result.status
  end
end