Class: CORL::Action::Exec

Inherits:
Plugin::CloudAction show all
Defined in:
lib/CORL/action/exec.rb

Instance Method Summary collapse

Methods inherited from Plugin::CloudAction

#ensure_network, #ensure_node, #execute_remote, #init_network, #namespace, #node_config, #node_exec, #node_ignore, #validate

Instance Method Details

#argumentsObject




17
18
19
# File 'lib/CORL/action/exec.rb', line 17

def arguments
  [ :command ]
end

#configureObject


Settings



9
10
11
12
13
# File 'lib/CORL/action/exec.rb', line 9

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

#executeObject


Operations



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/CORL/action/exec.rb', line 24

def execute
  super do |node, network|
    ensure_node(node) do
      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(' ')
      result        = node.exec({ :commands => [ command_str ] }).first
      myself.status = result.status
    end
  end
end