Class: Reacter::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/reacter/agent.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAgent

Returns a new instance of Agent.



13
14
15
16
17
# File 'lib/reacter/agent.rb', line 13

def initialize()
  @type = self.class.name.sub('Agent', '').split('::').last.downcase
  @config = Reacter.get("agents.#{@type}", {})
  Util.info("Loading agent #{@type}...")
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/reacter/agent.rb', line 10

def config
  @config
end

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/reacter/agent.rb', line 11

def type
  @type
end

Class Method Details

.create(type) ⇒ Object



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

def create(type)
  if type
    begin
      agentpath = Reacter['global.agents.path']
      $: << File.expand_path(agentpath) if agentpath

      require "reacter/agents/#{type}"
      rv = (Reacter.const_get("#{type.capitalize}Agent").new())
      return rv

    rescue LoadError
      STDERR.puts("#{e.class.name}: #{e.message}")
    end
  end

  nil
end

Instance Method Details

#received(message) ⇒ Object



19
20
21
# File 'lib/reacter/agent.rb', line 19

def received(message)
  false
end