| Class | MCollective::PluginPackager::AgentDefinition |
| In: |
lib/mcollective/pluginpackager/agent_definition.rb
|
| Parent: | Object |
MCollective Agent Plugin package
| dependencies | [RW] | |
| iteration | [RW] | |
| mcclient | [RW] | |
| mccommon | [RW] | |
| mcserver | [RW] | |
| metadata | [RW] | |
| packagedata | [RW] | |
| path | [RW] | |
| plugintype | [RW] | |
| postinstall | [RW] | |
| preinstall | [RW] | |
| target_path | [RW] | |
| vendor | [RW] |
# File lib/mcollective/pluginpackager/agent_definition.rb, line 8
8: def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcodependency, plugintype)
9: @plugintype = plugintype
10: @path = path
11: @packagedata = {}
12: @iteration = iteration || 1
13: @preinstall = preinstall
14: @postinstall = postinstall
15: @vendor = vendor || "Puppet Labs"
16: @mcserver = mcodependency[:server] || "mcollective"
17: @mcclient = mcodependency[:client] || "mcollective-client"
18: @mccommon = mcodependency[:common] || "mcollective-common"
19: @dependencies = dependencies || []
20: @target_path = File.expand_path(@path)
21: @metadata = PluginPackager.get_metadata(@path, "agent")
22: @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
23: identify_packages
24: end
Obtain Agent package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 37
37: def agent
38: agent = {:files => [],
39: :dependencies => @dependencies.clone << @mcserver,
40: :description => "Agent plugin for #{@metadata[:name]}"}
41:
42: agentdir = File.join(@path, "agent")
43:
44: if PluginPackager.check_dir_present agentdir
45: ddls = Dir.glob(File.join(agentdir, "*.ddl"))
46: agent[:files] = (Dir.glob(File.join(agentdir, "*")) - ddls)
47: implementations = Dir.glob(File.join(@metadata[:name], "**"))
48: agent[:files] += implementations unless implementations.empty?
49: else
50: return nil
51: end
52: agent[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
53: agent
54: end
Obtain client package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 57
57: def client
58: client = {:files => [],
59: :dependencies => @dependencies.clone << @mcclient,
60: :description => "Client plugin for #{@metadata[:name]}"}
61:
62: clientdir = File.join(@path, "application")
63: bindir = File.join(@path, "bin")
64: ddldir = File.join(@path, "agent")
65:
66: client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
67: client[:files] += Dir.glob(File.join(bindir,"*")) if PluginPackager.check_dir_present bindir
68: client[:files] += Dir.glob(File.join(ddldir, "*.ddl")) if PluginPackager.check_dir_present ddldir
69: client[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
70: client[:files].empty? ? nil : client
71: end
Obtain common package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 74
74: def common
75: common = {:files =>[],
76: :dependencies => @dependencies.clone << @mccommon,
77: :description => "Common libraries for #{@metadata[:name]}"}
78:
79: commondir = File.join(@path, "util")
80: common[:files] += Dir.glob(File.join(commondir,"*")) if PluginPackager.check_dir_present commondir
81: common[:files].empty? ? nil : common
82: end
Identify present packages and populate packagedata hash.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 27
27: def identify_packages
28: common_package = common
29: @packagedata[:common] = common_package if common_package
30: agent_package = agent
31: @packagedata[:agent] = agent_package if agent_package
32: client_package = client
33: @packagedata[:client] = client_package if client_package
34: end