Sha256: c3841f308854930ad538eabba0e5fecb59e9da142658ccfce8887030df72997c

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

module Nucleon
module Action
module Node
class Lookup < Nucleon.plugin_class(:nucleon, :cloud_action)
  
  #-----------------------------------------------------------------------------
  # Info
  
  def self.describe
    super(:node, :lookup, 565)
  end

  #-----------------------------------------------------------------------------
  # Settings
  
  def configure
    super do
      register :properties, :array, []
      register :context, :str, :priority do |value|
        success = true
        options = [ :priority, :array, :hash ]
        unless options.include?(value.to_sym)
          warn('corl.actions.lookup.errors.context', { :value => value, :options => options.join(', ') })
          success = false
        end
        success
      end
      
      register_translator :format, :json
    end
  end
  
  #---
  
  def arguments
    [ :properties ]
  end

  #-----------------------------------------------------------------------------
  # Operations
   
  def execute
    super do |node|
      ensure_node(node) do
        translator = CORL.translator({}, settings[:format])
        
        if settings[:properties].empty?
          myself.result = node.hiera_configuration(node.facts)
          $stderr.puts translator.generate(result)
        else
          properties = {}
          
          settings.delete(:properties).each do |property|
            properties[property] = node.lookup(property, nil, settings)
          end
          $stderr.puts translator.generate(properties)
          myself.result = properties 
        end        
      end
    end
  end
end
end
end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
corl-0.5.12 lib/nucleon/action/node/lookup.rb
corl-0.5.11 lib/nucleon/action/node/lookup.rb
corl-0.5.10 lib/nucleon/action/node/lookup.rb
corl-0.5.9 lib/nucleon/action/node/lookup.rb
corl-0.5.8 lib/nucleon/action/node/lookup.rb
corl-0.5.7 lib/nucleon/action/node/lookup.rb
corl-0.5.6 lib/nucleon/action/node/lookup.rb
corl-0.5.5 lib/nucleon/action/node/lookup.rb
corl-0.5.4 lib/nucleon/action/node/lookup.rb
corl-0.5.3 lib/nucleon/action/node/lookup.rb
corl-0.5.2 lib/nucleon/action/node/lookup.rb