Sha256: 27f8258903a8b811d7d08c195b55595a14e641c12c73e6ba05ff28ef1a491f02

Contents?: true

Size: 995 Bytes

Versions: 14

Compression:

Stored size: 995 Bytes

Contents

module CORL
module Action
class Exec < Plugin::CloudAction
 
  #----------------------------------------------------------------------------
  # Settings
  
  def configure
    super do
      codes :network_failure
            
      register :command, :array, nil
    end
  end
  
  #---
  
  def arguments
    [ :command ]
  end
 
  #-----------------------------------------------------------------------------
  # Operations
   
  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
end
end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
corl-0.4.15 lib/CORL/action/exec.rb
corl-0.4.14 lib/CORL/action/exec.rb
corl-0.4.13 lib/CORL/action/exec.rb
corl-0.4.12 lib/CORL/action/exec.rb
corl-0.4.11 lib/CORL/action/exec.rb
corl-0.4.10 lib/CORL/action/exec.rb
corl-0.4.9 lib/CORL/action/exec.rb
corl-0.4.8 lib/CORL/action/exec.rb
corl-0.4.7 lib/CORL/action/exec.rb
corl-0.4.6 lib/CORL/action/exec.rb
corl-0.4.5 lib/CORL/action/exec.rb
corl-0.4.4 lib/CORL/action/exec.rb
corl-0.4.3 lib/CORL/action/exec.rb
corl-0.4.2 lib/CORL/action/exec.rb