Class: MCollective::PluginPackager::AgentDefinition
- Inherits:
-
Object
- Object
- MCollective::PluginPackager::AgentDefinition
- Defined in:
- lib/mcollective/pluginpackager/agent_definition.rb
Overview
MCollective Agent Plugin package
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#mcname ⇒ Object
Returns the value of attribute mcname.
-
#mcversion ⇒ Object
Returns the value of attribute mcversion.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#packagedata ⇒ Object
Returns the value of attribute packagedata.
-
#path ⇒ Object
Returns the value of attribute path.
-
#plugintype ⇒ Object
Returns the value of attribute plugintype.
-
#postinstall ⇒ Object
Returns the value of attribute postinstall.
-
#preinstall ⇒ Object
Returns the value of attribute preinstall.
-
#revision ⇒ Object
Returns the value of attribute revision.
-
#target_path ⇒ Object
Returns the value of attribute target_path.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
Instance Method Summary collapse
-
#agent ⇒ Object
Obtain Agent package files and dependencies.
-
#client ⇒ Object
Obtain client package files and dependencies.
-
#common ⇒ Object
Obtain common package files and dependencies.
-
#identify_packages ⇒ Object
Identify present packages and populate packagedata hash.
-
#initialize(configuration, mcdependency, plugintype) ⇒ AgentDefinition
constructor
A new instance of AgentDefinition.
Constructor Details
#initialize(configuration, mcdependency, plugintype) ⇒ AgentDefinition
Returns a new instance of AgentDefinition.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 8 def initialize(configuration, mcdependency, plugintype) @plugintype = plugintype @path = PluginPackager.get_plugin_path(configuration[:target]) @packagedata = {} @revision = configuration[:revision] || 1 @preinstall = configuration[:preinstall] @postinstall = configuration[:postinstall] @vendor = configuration[:vendor] || "Puppet Labs" @dependencies = configuration[:dependency] || [] @target_path = File.(@path) @metadata, mcversion = PluginPackager.(@path, "agent") @mcname = mcdependency[:mcname] || "mcollective" @mcversion = mcdependency[:mcversion] || mcversion @metadata[:version] = (configuration[:version] || @metadata[:version]) @dependencies << {:name => "#{@mcname}-common", :version => @mcversion} @metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-") identify_packages end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
6 7 8 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 6 def dependencies @dependencies end |
#mcname ⇒ Object
Returns the value of attribute mcname.
6 7 8 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 6 def mcname @mcname end |
#mcversion ⇒ Object
Returns the value of attribute mcversion.
6 7 8 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 6 def mcversion @mcversion end |
#metadata ⇒ Object
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def @metadata end |
#packagedata ⇒ Object
Returns the value of attribute packagedata.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def packagedata @packagedata end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def path @path end |
#plugintype ⇒ Object
Returns the value of attribute plugintype.
6 7 8 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 6 def plugintype @plugintype end |
#postinstall ⇒ Object
Returns the value of attribute postinstall.
6 7 8 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 6 def postinstall @postinstall end |
#preinstall ⇒ Object
Returns the value of attribute preinstall.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def preinstall @preinstall end |
#revision ⇒ Object
Returns the value of attribute revision.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def revision @revision end |
#target_path ⇒ Object
Returns the value of attribute target_path.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def target_path @target_path end |
#vendor ⇒ Object
Returns the value of attribute vendor.
5 6 7 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 5 def vendor @vendor end |
Instance Method Details
#agent ⇒ Object
Obtain Agent package files and dependencies.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 38 def agent agent = {:files => [], :dependencies => @dependencies.clone, :description => "Agent plugin for #{@metadata[:name]}"} agentdir = File.join(@path, "agent") if (PluginPackager.check_dir_present(agentdir)) ddls = Dir.glob(File.join(agentdir, "*.ddl")) agent[:files] = (Dir.glob(File.join(agentdir, "**", "**")) - ddls) else return nil end agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision} agent end |
#client ⇒ Object
Obtain client package files and dependencies.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 56 def client client = {:files => [], :dependencies => @dependencies.clone, :description => "Client plugin for #{@metadata[:name]}"} clientdir = File.join(@path, "application") aggregatedir = File.join(@path, "aggregate") client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir client[:files] += Dir.glob(File.join(aggregatedir, "*")) if PluginPackager.check_dir_present aggregatedir client[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision} client[:files].empty? ? nil : client end |
#common ⇒ Object
Obtain common package files and dependencies.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 71 def common common = {:files =>[], :dependencies => @dependencies.clone, :description => "Common libraries for #{@metadata[:name]}"} datadir = File.join(@path, "data", "**") utildir = File.join(@path, "util", "**", "**") ddldir = File.join(@path, "agent", "*.ddl") validatordir = File.join(@path, "validator", "**") [datadir, utildir, validatordir, ddldir].each do |directory| common[:files] += Dir.glob(directory) end # We fail if there is no ddl file present if common[:files].grep(/^.*\.ddl$/).empty? raise "cannot create package - No ddl file found in #{File.join(@path, "agent")}" end common[:files].empty? ? nil : common end |
#identify_packages ⇒ Object
Identify present packages and populate packagedata hash.
28 29 30 31 32 33 34 35 |
# File 'lib/mcollective/pluginpackager/agent_definition.rb', line 28 def identify_packages common_package = common @packagedata[:common] = common_package if common_package agent_package = agent @packagedata[:agent] = agent_package if agent_package client_package = client @packagedata[:client] = client_package if client_package end |