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

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

Instance Method Details

#argumentsObject




19
20
21
# File 'lib/CORL/action/exec.rb', line 19

def arguments
  [ :command ]
end

#configureObject


Settings



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

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

#executeObject


Operations



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

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