mcollective-client 2.2.4 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mcollective-client might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/mcollective/application.rb +25 -34
- data/lib/mcollective/client.rb +91 -33
- data/lib/mcollective/config.rb +42 -43
- data/lib/mcollective/data/base.rb +1 -1
- data/lib/mcollective/data/result.rb +6 -2
- data/lib/mcollective/ddl/agentddl.rb +28 -1
- data/lib/mcollective/ddl/base.rb +8 -6
- data/lib/mcollective/log.rb +11 -3
- data/lib/mcollective/logger/file_logger.rb +4 -4
- data/lib/mcollective/matcher.rb +9 -1
- data/lib/mcollective/message.rb +14 -23
- data/lib/mcollective/optionparser.rb +9 -1
- data/lib/mcollective/pluginpackager.rb +24 -3
- data/lib/mcollective/pluginpackager/agent_definition.rb +12 -12
- data/lib/mcollective/pluginpackager/standard_definition.rb +12 -12
- data/lib/mcollective/rpc/agent.rb +15 -12
- data/lib/mcollective/rpc/client.rb +67 -31
- data/lib/mcollective/rpc/helpers.rb +7 -1
- data/lib/mcollective/rpc/reply.rb +3 -1
- data/lib/mcollective/shell.rb +45 -8
- data/lib/mcollective/util.rb +37 -1
- data/lib/mcollective/windows_daemon.rb +14 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/application_spec.rb +45 -26
- data/spec/unit/cache_spec.rb +3 -3
- data/spec/unit/client_spec.rb +269 -24
- data/spec/unit/config_spec.rb +89 -26
- data/spec/unit/data/base_spec.rb +1 -0
- data/spec/unit/data/result_spec.rb +19 -1
- data/spec/unit/data_spec.rb +3 -0
- data/spec/unit/ddl/agentddl_spec.rb +32 -0
- data/spec/unit/ddl/base_spec.rb +4 -0
- data/spec/unit/ddl/dataddl_spec.rb +1 -1
- data/spec/unit/log_spec.rb +44 -27
- data/spec/unit/logger/base_spec.rb +1 -1
- data/spec/unit/matcher_spec.rb +14 -0
- data/spec/unit/message_spec.rb +24 -0
- data/spec/unit/optionparser_spec.rb +99 -0
- data/spec/unit/pluginpackager/agent_definition_spec.rb +48 -17
- data/spec/unit/pluginpackager/standard_definition_spec.rb +44 -20
- data/spec/unit/pluginpackager_spec.rb +31 -7
- data/spec/unit/plugins/mcollective/agent/rpcutil_spec.rb +176 -0
- data/spec/unit/plugins/mcollective/application/plugin_spec.rb +81 -0
- data/spec/unit/plugins/mcollective/audit/logfile_spec.rb +44 -0
- data/spec/unit/plugins/mcollective/connector/activemq_spec.rb +118 -27
- data/spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb +168 -34
- data/spec/unit/plugins/mcollective/data/agent_data_spec.rb +1 -0
- data/spec/unit/plugins/mcollective/data/fstat_data_spec.rb +1 -0
- data/spec/unit/plugins/mcollective/discovery/flatfile_spec.rb +10 -0
- data/spec/unit/plugins/mcollective/discovery/stdin_spec.rb +65 -0
- data/spec/unit/plugins/mcollective/facts/yaml_facts_spec.rb +65 -0
- data/spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb +240 -219
- data/spec/unit/plugins/mcollective/packagers/modulepackage_packager_spec.rb +209 -0
- data/spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb +223 -109
- data/spec/unit/rpc/actionrunner_spec.rb +2 -1
- data/spec/unit/rpc/agent_spec.rb +130 -1
- data/spec/unit/rpc/client_spec.rb +169 -3
- data/spec/unit/security/base_spec.rb +0 -1
- data/spec/unit/shell_spec.rb +76 -3
- data/spec/unit/util_spec.rb +69 -1
- data/spec/unit/windows_daemon_spec.rb +30 -9
- metadata +104 -90
- data/spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb +0 -34
- data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +0 -424
- data/spec/unit/plugins/mcollective/validator/any_validator_spec.rb +0 -15
@@ -13,7 +13,7 @@ module MCollective
|
|
13
13
|
def initialize
|
14
14
|
@name = self.class.to_s.split("::").last.downcase
|
15
15
|
@ddl = DDL.new(@name, :data)
|
16
|
-
@result = Result.new
|
16
|
+
@result = Result.new(@ddl.dataquery_interface[:output])
|
17
17
|
@timeout = @ddl.meta[:timeout] || 1
|
18
18
|
|
19
19
|
startup_hook
|
@@ -6,8 +6,12 @@ module MCollective
|
|
6
6
|
# method_missing lookup strategy
|
7
7
|
undef :type if method_defined?(:type)
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize(outputs)
|
10
10
|
@data = {}
|
11
|
+
|
12
|
+
outputs.keys.each do |output|
|
13
|
+
@data[output] = Marshal.load(Marshal.dump(outputs[output].fetch(:default, nil)))
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def include?(key)
|
@@ -31,7 +35,7 @@ module MCollective
|
|
31
35
|
def method_missing(method, *args)
|
32
36
|
key = method.to_sym
|
33
37
|
|
34
|
-
raise
|
38
|
+
raise NoMethodError, "undefined local variable or method `%s'" % key unless include?(key)
|
35
39
|
|
36
40
|
@data[key]
|
37
41
|
end
|
@@ -21,7 +21,8 @@ module MCollective
|
|
21
21
|
# :type => :string,
|
22
22
|
# :validation => '^[\w\-\.]+$',
|
23
23
|
# :optional => false,
|
24
|
-
# :maxlength => 40
|
24
|
+
# :maxlength => 40,
|
25
|
+
# :default => "fqdn"
|
25
26
|
#
|
26
27
|
# output :fact,
|
27
28
|
# :description => "The name of the fact being returned",
|
@@ -82,6 +83,10 @@ module MCollective
|
|
82
83
|
# Sets the display preference to either :ok, :failed, :flatten or :always
|
83
84
|
# operates on action level
|
84
85
|
def display(pref)
|
86
|
+
if pref == :flatten
|
87
|
+
Log.warn("The display option :flatten is being deprecated and will be removed in the next minor release.")
|
88
|
+
end
|
89
|
+
|
85
90
|
# defaults to old behavior, complain if its supplied and invalid
|
86
91
|
unless [:ok, :failed, :flatten, :always].include?(pref)
|
87
92
|
raise "Display preference #{pref} is not valid, should be :ok, :failed, :flatten or :always"
|
@@ -146,6 +151,28 @@ module MCollective
|
|
146
151
|
PluginManager.find("aggregate").include?(method_name.to_s)
|
147
152
|
end
|
148
153
|
|
154
|
+
# For a given action and arguments look up the DDL interface to that action
|
155
|
+
# and if any arguments in the DDL have a :default value assign that to any
|
156
|
+
# input that does not have an argument in the input arguments
|
157
|
+
#
|
158
|
+
# This is intended to only be called on clients and not on servers as the
|
159
|
+
# clients should never be able to publish non compliant requests and the
|
160
|
+
# servers should really not tamper with incoming requests since doing so
|
161
|
+
# might raise validation errors that were not raised on the client breaking
|
162
|
+
# our fail-fast approach to input validation
|
163
|
+
def set_default_input_arguments(action, arguments)
|
164
|
+
input = action_interface(action)[:input]
|
165
|
+
|
166
|
+
return unless input
|
167
|
+
|
168
|
+
input.keys.each do |key|
|
169
|
+
if !arguments.include?(key) && !input[key][:default].nil? && !input[key][:optional]
|
170
|
+
Log.debug("Setting default value for input '%s' to '%s'" % [key, input[key][:default]])
|
171
|
+
arguments[key] = input[key][:default]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
149
176
|
# Helper to use the DDL to figure out if the remote call to an
|
150
177
|
# agent should be allowed based on action name and inputs.
|
151
178
|
def validate_rpc_request(action, arguments)
|
data/lib/mcollective/ddl/base.rb
CHANGED
@@ -36,18 +36,19 @@ module MCollective
|
|
36
36
|
#
|
37
37
|
# If no template name is provided one will be chosen based
|
38
38
|
# on the plugin type. If the provided template path is
|
39
|
-
# not absolute then the template will be loaded
|
40
|
-
#
|
39
|
+
# not absolute then the template will be loaded either from
|
40
|
+
# the config dir and if that does not exist, default to
|
41
|
+
# /etc/mcollective
|
41
42
|
def help(template=nil)
|
42
43
|
template = template_for_plugintype unless template
|
43
|
-
template =
|
44
|
+
template = Util.templatepath(template) unless Util.absolute_path?(template)
|
44
45
|
|
45
46
|
template = File.read(template)
|
46
47
|
meta = @meta
|
47
48
|
entities = @entities
|
48
49
|
|
49
50
|
unless template == "metadata-help.erb"
|
50
|
-
metadata_template =
|
51
|
+
metadata_template = Util.templatepath("metadata-help.erb")
|
51
52
|
metadata_template = File.read(metadata_template)
|
52
53
|
metastring = ERB.new(metadata_template, 0, '%')
|
53
54
|
metastring = metastring.result(binding)
|
@@ -66,7 +67,7 @@ module MCollective
|
|
66
67
|
when :agent
|
67
68
|
return "rpc-help.erb"
|
68
69
|
else
|
69
|
-
if File.exists?(
|
70
|
+
if File.exists?(Util.templatepath("#{@plugintype}-help.erb"))
|
70
71
|
return "#{@plugintype}-help.erb"
|
71
72
|
else
|
72
73
|
# Default help template gets loaded if plugintype-help does not exist.
|
@@ -144,7 +145,7 @@ module MCollective
|
|
144
145
|
raise DDLValidationError, "Cannot validate input %s: %s" % [key, e.to_s]
|
145
146
|
end
|
146
147
|
|
147
|
-
|
148
|
+
# Registers an input argument for a given action
|
148
149
|
#
|
149
150
|
# See the documentation for action for how to use this
|
150
151
|
def input(argument, properties)
|
@@ -159,6 +160,7 @@ module MCollective
|
|
159
160
|
@entities[entity][:input][argument] = {:prompt => properties[:prompt],
|
160
161
|
:description => properties[:description],
|
161
162
|
:type => properties[:type],
|
163
|
+
:default => properties[:default],
|
162
164
|
:optional => properties[:optional]}
|
163
165
|
|
164
166
|
case properties[:type]
|
data/lib/mcollective/log.rb
CHANGED
@@ -81,13 +81,15 @@ module MCollective
|
|
81
81
|
end
|
82
82
|
|
83
83
|
require "mcollective/logger/#{logger_type.downcase}_logger"
|
84
|
-
|
84
|
+
|
85
|
+
logger_class = MCollective::Logger.const_get("#{logger_type.capitalize}_logger")
|
86
|
+
|
87
|
+
set_logger(logger_class.new)
|
85
88
|
else
|
86
89
|
set_logger(logger)
|
87
90
|
@configured = true
|
88
91
|
end
|
89
92
|
|
90
|
-
|
91
93
|
@logger.start
|
92
94
|
rescue Exception => e
|
93
95
|
@configured = false
|
@@ -96,7 +98,13 @@ module MCollective
|
|
96
98
|
|
97
99
|
# figures out the filename that called us
|
98
100
|
def from
|
99
|
-
|
101
|
+
path, line, method = execution_stack[3].split(/:(\d+)/)
|
102
|
+
"%s:%s%s" % [File.basename(path), line, method]
|
103
|
+
end
|
104
|
+
|
105
|
+
# this method is here to facilitate testing and from
|
106
|
+
def execution_stack
|
107
|
+
caller
|
100
108
|
end
|
101
109
|
end
|
102
110
|
end
|
@@ -28,10 +28,10 @@ module MCollective
|
|
28
28
|
|
29
29
|
def valid_levels
|
30
30
|
{:info => ::Logger::INFO,
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
:warn => ::Logger::WARN,
|
32
|
+
:debug => ::Logger::DEBUG,
|
33
|
+
:fatal => ::Logger::FATAL,
|
34
|
+
:error => ::Logger::ERROR}
|
35
35
|
end
|
36
36
|
|
37
37
|
def log(level, from, msg)
|
data/lib/mcollective/matcher.rb
CHANGED
@@ -96,7 +96,12 @@ module MCollective
|
|
96
96
|
result = Data.send(function_hash["name"], function_hash["params"])
|
97
97
|
|
98
98
|
if function_hash["value"]
|
99
|
-
|
99
|
+
begin
|
100
|
+
eval_result = result.send(function_hash["value"])
|
101
|
+
rescue
|
102
|
+
# If data field has not been set we set the comparison result to nil
|
103
|
+
eval_result = nil
|
104
|
+
end
|
100
105
|
return eval_result
|
101
106
|
else
|
102
107
|
return result
|
@@ -130,6 +135,9 @@ module MCollective
|
|
130
135
|
def self.eval_compound_fstatement(function_hash)
|
131
136
|
l_compare = execute_function(function_hash)
|
132
137
|
|
138
|
+
# Break out early and return false if the function returns nil
|
139
|
+
return false unless l_compare
|
140
|
+
|
133
141
|
# Prevent unwanted discovery by limiting comparison operators
|
134
142
|
# on Strings and Booleans
|
135
143
|
if((l_compare.is_a?(String) || l_compare.is_a?(TrueClass) || l_compare.is_a?(FalseClass)) && function_hash["operator"].match(/<|>/))
|
data/lib/mcollective/message.rb
CHANGED
@@ -139,7 +139,7 @@ module MCollective
|
|
139
139
|
@requestid = request.payload[:requestid]
|
140
140
|
@payload = PluginManager["security_plugin"].encodereply(agent, payload, requestid, request.payload[:callerid])
|
141
141
|
when :request, :direct_request
|
142
|
-
|
142
|
+
validate_compound_filter(@filter["compound"]) unless @filter["compound"].empty?
|
143
143
|
|
144
144
|
@requestid = create_reqid unless @requestid
|
145
145
|
@payload = PluginManager["security_plugin"].encoderequest(Config.instance.identity, payload, requestid, filter, agent, collective, ttl)
|
@@ -148,7 +148,7 @@ module MCollective
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
def
|
151
|
+
def validate_compound_filter(compound_filter)
|
152
152
|
compound_filter.each do |filter|
|
153
153
|
filter.each do |statement|
|
154
154
|
if statement["fstatement"]
|
@@ -156,11 +156,7 @@ module MCollective
|
|
156
156
|
pluginname = Data.pluginname(functionname)
|
157
157
|
value = statement["fstatement"]["value"]
|
158
158
|
|
159
|
-
|
160
|
-
ddl = DDL.new(pluginname, :data)
|
161
|
-
rescue
|
162
|
-
raise DDLValidationError, "Could not find DDL for data plugin #{pluginname}, cannot use #{functionname}() in discovery"
|
163
|
-
end
|
159
|
+
ddl = DDL.new(pluginname, :data)
|
164
160
|
|
165
161
|
# parses numbers and booleans entered as strings into proper
|
166
162
|
# types of data so that DDL validation will pass
|
@@ -169,7 +165,7 @@ module MCollective
|
|
169
165
|
Data.ddl_validate(ddl, statement["fstatement"]["params"])
|
170
166
|
|
171
167
|
unless value && Data.ddl_has_output?(ddl, value)
|
172
|
-
|
168
|
+
DDL.validation_fail!(:PLMC41, "Data plugin '%{functionname}()' does not return a '%{value}' value", :error, {:functionname => functionname, :value => value})
|
173
169
|
end
|
174
170
|
end
|
175
171
|
end
|
@@ -204,7 +200,7 @@ module MCollective
|
|
204
200
|
if msg_age > ttl
|
205
201
|
PluginManager["global_stats"].ttlexpired
|
206
202
|
|
207
|
-
raise(MsgTTLExpired, "
|
203
|
+
raise(MsgTTLExpired, "message #{requestid} from #{cid} created at #{msgtime} is #{msg_age} seconds old, TTL is #{ttl}")
|
208
204
|
end
|
209
205
|
end
|
210
206
|
|
@@ -215,21 +211,16 @@ module MCollective
|
|
215
211
|
|
216
212
|
# publish a reply message by creating a target name and sending it
|
217
213
|
def publish
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
Log.debug("Handling #{requestid} as a direct request")
|
226
|
-
end
|
227
|
-
|
228
|
-
PluginManager["connector_plugin"].publish(self)
|
229
|
-
else
|
230
|
-
PluginManager["connector_plugin"].publish(self)
|
231
|
-
end
|
214
|
+
# If we've been specificaly told about hosts that were discovered
|
215
|
+
# use that information to do P2P calls if appropriate else just
|
216
|
+
# send it as is.
|
217
|
+
config = Config.instance
|
218
|
+
if @discovered_hosts && config.direct_addressing && (@discovered_hosts.size <= config.direct_addressing_threshold)
|
219
|
+
self.type = :direct_request
|
220
|
+
Log.debug("Handling #{requestid} as a direct request")
|
232
221
|
end
|
222
|
+
|
223
|
+
PluginManager['connector_plugin'].publish(self)
|
233
224
|
end
|
234
225
|
|
235
226
|
def create_reqid
|
@@ -167,7 +167,15 @@ module MCollective
|
|
167
167
|
raise "Cannot read the discovery file #{v}" unless File.readable?(v)
|
168
168
|
|
169
169
|
@options[:discovery_method] = "flatfile"
|
170
|
-
@options[:discovery_options]
|
170
|
+
@options[:discovery_options] << v
|
171
|
+
end
|
172
|
+
|
173
|
+
@parser.on("--publish_timeout TIMEOUT", Integer, "Timeout for publishing requests to remote agents.") do |pt|
|
174
|
+
@options[:publish_timeout] = pt
|
175
|
+
end
|
176
|
+
|
177
|
+
@parser.on("--threaded", "Start publishing requests and receiving responses in threaded mode.") do |v|
|
178
|
+
@options[:threaded] = true
|
171
179
|
end
|
172
180
|
end
|
173
181
|
|
@@ -33,7 +33,7 @@ module MCollective
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Quietly calls a block if verbose parameter is false
|
36
|
-
def self.
|
36
|
+
def self.execute_verbosely(verbose, &block)
|
37
37
|
unless verbose
|
38
38
|
old_stdout = $stdout.clone
|
39
39
|
$stdout.reopen(File.new("/dev/null", "w"))
|
@@ -51,7 +51,7 @@ module MCollective
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# Checks if a build tool is present on the system
|
54
|
-
def self.
|
54
|
+
def self.command_available?(build_tool)
|
55
55
|
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
56
56
|
builder = File.join(path, build_tool)
|
57
57
|
if File.exists?(builder)
|
@@ -62,7 +62,28 @@ module MCollective
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.safe_system(*args)
|
65
|
-
raise
|
65
|
+
raise(RuntimeError, "Failed: #{args.join(' ')}") unless system *args
|
66
|
+
end
|
67
|
+
|
68
|
+
# Filter out platform specific dependencies
|
69
|
+
# Given a list of dependencies named -
|
70
|
+
# debian::foo
|
71
|
+
# redhat::bar
|
72
|
+
# PluginPackager.filter_dependencies('debian', dependencies)
|
73
|
+
# will return foo.
|
74
|
+
def self.filter_dependencies(prefix, dependencies)
|
75
|
+
dependencies.map do |dependency|
|
76
|
+
if dependency[:name] =~ /^(\w+)::(\w+)/
|
77
|
+
if prefix == $1
|
78
|
+
dependency[:name] = $2
|
79
|
+
dependency
|
80
|
+
else
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
else
|
84
|
+
dependency
|
85
|
+
end
|
86
|
+
end.reject{ |dependency| dependency == nil }
|
66
87
|
end
|
67
88
|
end
|
68
89
|
end
|
@@ -2,25 +2,25 @@ module MCollective
|
|
2
2
|
module PluginPackager
|
3
3
|
# MCollective Agent Plugin package
|
4
4
|
class AgentDefinition
|
5
|
-
attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :
|
5
|
+
attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :revision, :preinstall
|
6
6
|
attr_accessor :plugintype, :dependencies, :postinstall, :mcname, :mcversion
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(configuration, mcdependency, plugintype)
|
9
9
|
@plugintype = plugintype
|
10
|
-
@path =
|
10
|
+
@path = configuration[:target]
|
11
11
|
@packagedata = {}
|
12
|
-
@
|
13
|
-
@preinstall = preinstall
|
14
|
-
@postinstall = postinstall
|
15
|
-
@vendor = vendor || "Puppet Labs"
|
16
|
-
@dependencies =
|
12
|
+
@revision = configuration[:revision] || 1
|
13
|
+
@preinstall = configuration[:preinstall]
|
14
|
+
@postinstall = configuration[:postinstall]
|
15
|
+
@vendor = configuration[:vendor] || "Puppet Labs"
|
16
|
+
@dependencies = configuration[:dependency] || []
|
17
17
|
@target_path = File.expand_path(@path)
|
18
18
|
@metadata, mcversion = PluginPackager.get_metadata(@path, "agent")
|
19
19
|
@mcname = mcdependency[:mcname] || "mcollective"
|
20
20
|
@mcversion = mcdependency[:mcversion] || mcversion
|
21
|
+
@metadata[:version] = (configuration[:version] || @metadata[:version])
|
21
22
|
@dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
|
22
|
-
|
23
|
-
@metadata[:name] = (name || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
23
|
+
@metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
24
24
|
identify_packages
|
25
25
|
end
|
26
26
|
|
@@ -48,7 +48,7 @@ module MCollective
|
|
48
48
|
else
|
49
49
|
return nil
|
50
50
|
end
|
51
|
-
agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :
|
51
|
+
agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision}
|
52
52
|
agent
|
53
53
|
end
|
54
54
|
|
@@ -63,7 +63,7 @@ module MCollective
|
|
63
63
|
|
64
64
|
client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
|
65
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], :
|
66
|
+
client[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision}
|
67
67
|
client[:files].empty? ? nil : client
|
68
68
|
end
|
69
69
|
|
@@ -1,25 +1,25 @@
|
|
1
1
|
module MCollective
|
2
2
|
module PluginPackager
|
3
3
|
class StandardDefinition
|
4
|
-
attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :
|
4
|
+
attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :revision
|
5
5
|
attr_accessor :plugintype, :preinstall, :postinstall, :dependencies, :mcname, :mcversion
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize(configuration, mcdependency, plugintype)
|
8
8
|
@plugintype = plugintype
|
9
|
-
@path =
|
9
|
+
@path = configuration[:target]
|
10
10
|
@packagedata = {}
|
11
|
-
@
|
12
|
-
@preinstall = preinstall
|
13
|
-
@postinstall = postinstall
|
14
|
-
@vendor = vendor || "Puppet Labs"
|
15
|
-
@dependencies =
|
11
|
+
@revision = configuration[:revision] || 1
|
12
|
+
@preinstall = configuration[:preinstall]
|
13
|
+
@postinstall = configuration[:postinstall]
|
14
|
+
@vendor = configuration[:vendor] || "Puppet Labs"
|
15
|
+
@dependencies = configuration[:dependency] || []
|
16
16
|
@target_path = File.expand_path(@path)
|
17
17
|
@metadata, mcversion = PluginPackager.get_metadata(@path, @plugintype)
|
18
|
-
|
19
18
|
@mcname = mcdependency[:mcname] || "mcollective"
|
20
19
|
@mcversion = mcdependency[:mcversion] || mcversion
|
21
20
|
@dependencies << {:name => "#{mcname}-common", :version => @mcversion}
|
22
|
-
@metadata[:name] = (
|
21
|
+
@metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
22
|
+
@metadata[:version] = (configuration[:version] || @metadata[:version])
|
23
23
|
identify_packages
|
24
24
|
end
|
25
25
|
|
@@ -28,7 +28,7 @@ module MCollective
|
|
28
28
|
common_package = common
|
29
29
|
@packagedata[:common] = common_package if common_package
|
30
30
|
plugin_package = plugin
|
31
|
-
@packagedata[@plugintype] = plugin_package if plugin_package
|
31
|
+
@packagedata[@plugintype.to_sym] = plugin_package if plugin_package
|
32
32
|
end
|
33
33
|
|
34
34
|
# Obtain standard plugin files and dependencies
|
@@ -46,7 +46,7 @@ module MCollective
|
|
46
46
|
|
47
47
|
plugindata[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common",
|
48
48
|
:version => @metadata[:version],
|
49
|
-
:
|
49
|
+
:revision => @revision} if @packagedata[:common]
|
50
50
|
plugindata
|
51
51
|
end
|
52
52
|
|