| Class | MCollective::PluginPackager::AgentDefinition |
| In: |
lib/mcollective/pluginpackager/agent_definition.rb
|
| Parent: | Object |
MCollective Agent Plugin package
| dependencies | [RW] | |
| iteration | [RW] | |
| mcname | [RW] | |
| mcversion | [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, mcdependency, 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: @dependencies = dependencies || []
17: @target_path = File.expand_path(@path)
18: @metadata, mcversion = PluginPackager.get_metadata(@path, "agent")
19: @mcname = mcdependency[:mcname] || "mcollective"
20: @mcversion = mcdependency[:mcversion] || mcversion
21: @dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
22:
23: @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
24: identify_packages
25: end
Obtain Agent package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 38
38: def agent
39: agent = {:files => [],
40: :dependencies => @dependencies.clone,
41: :description => "Agent plugin for #{@metadata[:name]}"}
42:
43: agentdir = File.join(@path, "agent")
44:
45: if PluginPackager.check_dir_present agentdir
46: ddls = Dir.glob(File.join(agentdir, "*.ddl"))
47: agent[:files] = (Dir.glob(File.join(agentdir, "*")) - ddls)
48: else
49: return nil
50: end
51: agent[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version]}
52: agent
53: end
Obtain client package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 56
56: def client
57: client = {:files => [],
58: :dependencies => @dependencies.clone,
59: :description => "Client plugin for #{@metadata[:name]}"}
60:
61: clientdir = File.join(@path, "application")
62: aggregatedir = File.join(@path, "aggregate")
63:
64: client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
65: client[:files] += Dir.glob(File.join(aggregatedir, "*")) if PluginPackager.check_dir_present aggregatedir
66: client[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version]}
67: client[:files].empty? ? nil : client
68: end
Obtain common package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 71
71: def common
72: common = {:files =>[],
73: :dependencies => @dependencies.clone,
74: :description => "Common libraries for #{@metadata[:name]}"}
75:
76: datadir = File.join(@path, "data", "**")
77: utildir = File.join(@path, "util", "**", "**")
78: ddldir = File.join(@path, "agent", "*.ddl")
79: validatordir = File.join(@path, "validator", "**")
80:
81: [datadir, utildir, validatordir, ddldir].each do |directory|
82: common[:files] += Dir.glob(directory)
83: end
84:
85: # We fail if there is no ddl file present
86: if common[:files].grep(/^.*\.ddl$/).empty?
87: raise "cannot create package - No ddl file found in #{File.join(@path, "agent")}"
88: end
89:
90: common[:files].empty? ? nil : common
91: end
Identify present packages and populate packagedata hash.
# File lib/mcollective/pluginpackager/agent_definition.rb, line 28
28: def identify_packages
29: common_package = common
30: @packagedata[:common] = common_package if common_package
31: agent_package = agent
32: @packagedata[:agent] = agent_package if agent_package
33: client_package = client
34: @packagedata[:client] = client_package if client_package
35: end