Class MCollective::PluginPackager::AgentDefinition
In: lib/mcollective/pluginpackager/agent_definition.rb
Parent: Object

MCollective Agent Plugin package

Methods

agent   client   common   identify_packages   new  

Attributes

iteration  [RW] 
metadata  [RW] 
packagedata  [RW] 
path  [RW] 
plugintype  [RW] 
postinstall  [RW] 
target_path  [RW] 
vendor  [RW] 

Public Class methods

[Source]

    # File lib/mcollective/pluginpackager/agent_definition.rb, line 8
 8:       def initialize(path, name, vendor, postinstall, iteration, plugintype)
 9:         @plugintype = plugintype
10:         @path = path
11:         @packagedata = {}
12:         @iteration = iteration || 1
13:         @postinstall = postinstall
14:         @vendor = vendor || "Puppet Labs"
15:         @target_path = File.expand_path(@path)
16:         @metadata = PluginPackager.get_metadata(@path, "agent")
17:         @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "_")
18:         identify_packages
19:       end

Public Instance methods

Obtain Agent package files and dependencies.

[Source]

    # File lib/mcollective/pluginpackager/agent_definition.rb, line 29
29:       def agent
30:         agent = {:files => [],
31:                  :dependencies => ["mcollective"],
32:                  :description => "Agent plugin for #{@metadata[:name]}"}
33: 
34:         agentdir = File.join(@path, "agent")
35: 
36:         if PluginPackager.check_dir_present agentdir
37:           ddls = Dir.glob(File.join(agentdir, "*.ddl"))
38:           agent[:files] = (Dir.glob(File.join(agentdir, "*")) - ddls)
39:           implementations = Dir.glob(File.join(@metadata[:name], "**"))
40:           agent[:files] += implementations unless implementations.empty?
41:         else
42:           return nil
43:         end
44: 
45:         agent[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
46:         agent
47:       end

Obtain client package files and dependencies.

[Source]

    # File lib/mcollective/pluginpackager/agent_definition.rb, line 50
50:       def client
51:         client = {:files => [],
52:                   :dependencies => ["mcollective-client"],
53:                   :description => "Client plugin for #{@metadata[:name]}"}
54: 
55:         clientdir = File.join(@path, "application")
56:         bindir = File.join(@path, "bin")
57:         ddldir = File.join(@path, "agent")
58: 
59:         client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
60:         client[:files] += Dir.glob(File.join(bindir,"*")) if PluginPackager.check_dir_present bindir
61:         client[:files] += Dir.glob(File.join(ddldir, "*.ddl")) if PluginPackager.check_dir_present ddldir
62:         client[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
63:         client[:files].empty? ? nil : client
64:       end

Obtain common package files and dependencies.

[Source]

    # File lib/mcollective/pluginpackager/agent_definition.rb, line 67
67:       def common
68:         common = {:files =>[],
69:                   :dependencies => ["mcollective-common"],
70:                   :description => "Common libraries for #{@metadata[:name]}"}
71: 
72:         commondir = File.join(@path, "util")
73:         common[:files] += Dir.glob(File.join(commondir,"*")) if PluginPackager.check_dir_present commondir
74:         common[:files].empty? ? nil : common
75:       end

Identify present packages and populate packagedata hash.

[Source]

    # File lib/mcollective/pluginpackager/agent_definition.rb, line 22
22:       def identify_packages
23:         @packagedata[:common] = common
24:         @packagedata[:agent] = agent
25:         @packagedata[:client] = client
26:       end

[Validate]