class MCollective::PluginPackager::AgentDefinition
MCollective
Agent
Plugin package
Attributes
dependencies[RW]
mcname[RW]
mcversion[RW]
metadata[RW]
packagedata[RW]
path[RW]
plugintype[RW]
postinstall[RW]
preinstall[RW]
revision[RW]
target_path[RW]
vendor[RW]
Public Class Methods
new(configuration, mcdependency, plugintype)
click to toggle source
# File lib/mcollective/pluginpackager/agent_definition.rb 8 def initialize(configuration, mcdependency, plugintype) 9 @plugintype = plugintype 10 @path = PluginPackager.get_plugin_path(configuration[:target]) 11 @packagedata = {} 12 @revision = configuration[:revision] || 1 13 @preinstall = configuration[:preinstall] 14 @postinstall = configuration[:postinstall] 15 @vendor = configuration[:vendor] || "Puppet Labs" 16 @dependencies = configuration[:dependency] || [] 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 @metadata[:version] = (configuration[:version] || @metadata[:version]) 22 @dependencies << {:name => "#{@mcname}-common", :version => @mcversion} 23 @metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-") 24 identify_packages 25 end
Public Instance Methods
agent()
click to toggle source
Obtain Agent
package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb 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[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision} 52 agent 53 end
client()
click to toggle source
Obtain client package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb 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[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision} 67 client[:files].empty? ? nil : client 68 end
common()
click to toggle source
Obtain common package files and dependencies.
# File lib/mcollective/pluginpackager/agent_definition.rb 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_packages()
click to toggle source
Identify present packages and populate packagedata hash.
# File lib/mcollective/pluginpackager/agent_definition.rb 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