choria-mcorpc-support 2.23.3 → 2.24.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/mcollective.rb +3 -3
- data/lib/mcollective/agent/choria_provision.ddl +214 -0
- data/lib/mcollective/agent/choria_provision.json +272 -0
- data/lib/mcollective/agent/choria_util.ddl +226 -107
- data/lib/mcollective/agent/choria_util.json +125 -25
- data/lib/mcollective/agent/rpcutil.ddl +242 -183
- data/lib/mcollective/agent/rpcutil.json +53 -57
- data/lib/mcollective/agent/scout.ddl +1 -1
- data/lib/mcollective/agent/scout.json +108 -136
- data/lib/mcollective/application/find.rb +1 -1
- data/lib/mcollective/application/plugin.rb +8 -173
- data/lib/mcollective/client.rb +1 -1
- data/lib/mcollective/config.rb +145 -103
- data/lib/mcollective/ddl.rb +0 -1
- data/lib/mcollective/discovery.rb +11 -63
- data/lib/mcollective/discovery/broadcast.ddl +11 -0
- data/lib/mcollective/discovery/choria.ddl +6 -4
- data/lib/mcollective/discovery/delegate.ddl +13 -0
- data/lib/mcollective/discovery/delegate.rb +72 -0
- data/lib/mcollective/discovery/external.ddl +13 -0
- data/lib/mcollective/discovery/file.ddl +13 -0
- data/lib/mcollective/discovery/flatfile.ddl +7 -5
- data/lib/mcollective/discovery/inventory.ddl +13 -0
- data/lib/mcollective/discovery/mc.ddl +3 -3
- data/lib/mcollective/log.rb +1 -2
- data/lib/mcollective/optionparser.rb +1 -1
- data/lib/mcollective/pluginpackager/forge_packager.rb +1 -1
- data/lib/mcollective/rpc/client.rb +4 -2
- data/lib/mcollective/util.rb +2 -4
- data/lib/mcollective/util/choria.rb +14 -8
- data/lib/mcollective/util/tasks_support.rb +15 -2
- metadata +11 -29
- data/lib/mcollective/data.rb +0 -96
- data/lib/mcollective/data/agent_data.ddl +0 -22
- data/lib/mcollective/data/agent_data.rb +0 -17
- data/lib/mcollective/data/base.rb +0 -68
- data/lib/mcollective/data/bolt_task_data.ddl +0 -90
- data/lib/mcollective/data/bolt_task_data.rb +0 -32
- data/lib/mcollective/data/collective_data.ddl +0 -20
- data/lib/mcollective/data/collective_data.rb +0 -9
- data/lib/mcollective/data/fact_data.ddl +0 -28
- data/lib/mcollective/data/fact_data.rb +0 -55
- data/lib/mcollective/data/fstat_data.ddl +0 -89
- data/lib/mcollective/data/fstat_data.rb +0 -54
- data/lib/mcollective/data/result.rb +0 -50
- data/lib/mcollective/ddl/dataddl.rb +0 -56
- data/lib/mcollective/discovery/choria.rb +0 -223
- data/lib/mcollective/discovery/flatfile.rb +0 -47
- data/lib/mcollective/discovery/stdin.ddl +0 -11
- data/lib/mcollective/discovery/stdin.rb +0 -67
- data/lib/mcollective/generators.rb +0 -7
- data/lib/mcollective/generators/agent_generator.rb +0 -50
- data/lib/mcollective/generators/base.rb +0 -45
- data/lib/mcollective/generators/data_generator.rb +0 -50
- data/lib/mcollective/generators/templates/action_snippet.erb +0 -13
- data/lib/mcollective/generators/templates/data_input_snippet.erb +0 -7
- data/lib/mcollective/generators/templates/ddl.erb +0 -8
- data/lib/mcollective/generators/templates/plugin.erb +0 -7
@@ -16,7 +16,7 @@ class MCollective::Application::Find < MCollective::Application # rubocop:disabl
|
|
16
16
|
|
17
17
|
nodes.each {|c| puts c}
|
18
18
|
|
19
|
-
warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.
|
19
|
+
warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.options[:discovery_method]] if options[:verbose]
|
20
20
|
|
21
21
|
!nodes.empty? ? exit(0) : exit(1)
|
22
22
|
end
|
@@ -8,19 +8,14 @@ mco plugin package [options] <directory>
|
|
8
8
|
mco plugin info <directory>
|
9
9
|
mco plugin doc <plugin>
|
10
10
|
mco plugin doc <type/plugin>
|
11
|
-
mco plugin generate
|
12
|
-
mco plugin generate
|
11
|
+
mco plugin generate client <ddl> <target>
|
12
|
+
mco plugin generate ddl <json_output> <ruby_output>
|
13
13
|
|
14
14
|
info : Display plugin information including package details.
|
15
15
|
package : Create all available plugin packages.
|
16
16
|
doc : Display documentation for a specific plugin.
|
17
17
|
END_OF_USAGE
|
18
18
|
|
19
|
-
option :pluginname,
|
20
|
-
:description => "Plugin name",
|
21
|
-
:arguments => ["-n", "--name NAME"],
|
22
|
-
:type => String
|
23
|
-
|
24
19
|
option :postinstall,
|
25
20
|
:description => "Post install script",
|
26
21
|
:arguments => ["--postinstall POSTINSTALL"],
|
@@ -67,7 +62,7 @@ mco plugin package [options] <directory>
|
|
67
62
|
:type => :array
|
68
63
|
|
69
64
|
option :format,
|
70
|
-
:description => "Package output format. Defaults to
|
65
|
+
:description => "Package output format. Defaults to forge",
|
71
66
|
:arguments => ["--format OUTPUTFORMAT"],
|
72
67
|
:type => String
|
73
68
|
|
@@ -81,46 +76,11 @@ mco plugin package [options] <directory>
|
|
81
76
|
:arguments => ["--template HELPTEMPLATE"],
|
82
77
|
:type => String
|
83
78
|
|
84
|
-
option :description,
|
85
|
-
:description => "Plugin description",
|
86
|
-
:arguments => ["--description DESCRIPTION"],
|
87
|
-
:type => String
|
88
|
-
|
89
|
-
option :author,
|
90
|
-
:description => "The author of the plugin",
|
91
|
-
:arguments => ["--author AUTHOR"],
|
92
|
-
:type => String
|
93
|
-
|
94
|
-
option :license,
|
95
|
-
:description => "The license under which the plugin is distributed",
|
96
|
-
:arguments => ["--license LICENSE"],
|
97
|
-
:type => String
|
98
|
-
|
99
79
|
option :version,
|
100
80
|
:description => "The version of the plugin",
|
101
81
|
:arguments => ["--pluginversion VERSION"],
|
102
82
|
:type => String
|
103
83
|
|
104
|
-
option :url,
|
105
|
-
:description => "Url at which information about the plugin can be found",
|
106
|
-
:arguments => ["--url URL"],
|
107
|
-
:type => String
|
108
|
-
|
109
|
-
option :timeout,
|
110
|
-
:description => "The plugin's timeout",
|
111
|
-
:arguments => ["--timeout TIMEOUT"],
|
112
|
-
:type => Integer
|
113
|
-
|
114
|
-
option :actions,
|
115
|
-
:description => "Actions to be generated for an Agent Plugin",
|
116
|
-
:arguments => ["--actions [ACTIONS]"],
|
117
|
-
:type => Array
|
118
|
-
|
119
|
-
option :outputs,
|
120
|
-
:description => "Outputs to be generated for an Data Plugin",
|
121
|
-
:arguments => ["--outputs [OUTPUTS]"],
|
122
|
-
:type => Array
|
123
|
-
|
124
84
|
option :keep_artifacts,
|
125
85
|
:description => "Don't remove artifacts after building packages",
|
126
86
|
:arguments => ["--keep-artifacts"],
|
@@ -137,59 +97,12 @@ mco plugin package [options] <directory>
|
|
137
97
|
configuration[:action] = ARGV.delete_at(0)
|
138
98
|
|
139
99
|
configuration[:target] = ARGV.delete_at(0) || "."
|
140
|
-
|
141
|
-
if configuration[:action] == "generate"
|
142
|
-
unless ARGV[0] && ARGV[0].match(/(actions|outputs)=(.+)/i)
|
143
|
-
if configuration[:pluginname] # rubocop:disable Metrics/BlockNesting
|
144
|
-
ARGV.delete_at(0)
|
145
|
-
else
|
146
|
-
configuration[:pluginname] = ARGV.delete_at(0)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
ARGV.each do |argument|
|
151
|
-
if argument.match(/(actions|outputs)=(.+)/i)
|
152
|
-
configuration[$1.downcase.to_sym] = $2.split(",")
|
153
|
-
else
|
154
|
-
raise "Could not parse --arg '#{argument}'"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
100
|
end
|
159
101
|
end
|
160
102
|
|
161
|
-
# Display info about plugin
|
162
|
-
def info_command
|
163
|
-
plugin = prepare_plugin
|
164
|
-
packager = PluginPackager["#{configuration[:format].capitalize}Packager"]
|
165
|
-
packager.new(plugin).package_information
|
166
|
-
end
|
167
|
-
|
168
103
|
# Generate a plugin skeleton
|
169
104
|
def generate_command
|
170
|
-
|
171
|
-
|
172
|
-
unless configuration[:pluginname]
|
173
|
-
puts "No plugin name specified. Using 'new_plugin'"
|
174
|
-
configuration[:pluginname] = "new_plugin"
|
175
|
-
end
|
176
|
-
|
177
|
-
load_plugin_config_values
|
178
|
-
|
179
|
-
case configuration[:target].downcase
|
180
|
-
when "agent"
|
181
|
-
Generators::AgentGenerator.new(configuration[:pluginname], configuration[:actions], configuration[:pluginname],
|
182
|
-
configuration[:description], configuration[:author], configuration[:license],
|
183
|
-
configuration[:version], configuration[:url], configuration[:timeout])
|
184
|
-
when "data"
|
185
|
-
raise "data plugin must have at least one output" unless configuration[:outputs]
|
186
|
-
|
187
|
-
Generators::DataGenerator.new(configuration[:pluginname], configuration[:outputs], configuration[:pluginname],
|
188
|
-
configuration[:description], configuration[:author], configuration[:license],
|
189
|
-
configuration[:version], configuration[:url], configuration[:timeout])
|
190
|
-
else
|
191
|
-
raise "invalid plugin type. cannot generate plugin '#{configuration[:target]}'"
|
192
|
-
end
|
105
|
+
puts "CRITICAL: mco plugin generate is deprecated, please use 'choria plugin generate'"
|
193
106
|
end
|
194
107
|
|
195
108
|
# Package plugin
|
@@ -223,76 +136,10 @@ mco plugin package [options] <directory>
|
|
223
136
|
end
|
224
137
|
|
225
138
|
# Show application list and plugin help
|
226
|
-
def doc_command
|
227
|
-
|
228
|
-
["Agents", :agent],
|
229
|
-
["Aggregate", :aggregate],
|
230
|
-
["Connectors", :connector],
|
231
|
-
["Data Queries", :data],
|
232
|
-
["Discovery Methods", :discovery],
|
233
|
-
["Validator Plugins", :validator]
|
234
|
-
]
|
235
|
-
|
236
|
-
if configuration.include?(:target) && configuration[:target] != "."
|
237
|
-
if configuration[:target] =~ /^(.+?)\/(.+)$/
|
238
|
-
ddl = load_plugin_ddl($2.to_sym, $1)
|
239
|
-
else
|
240
|
-
found_plugin_type = nil
|
241
|
-
|
242
|
-
known_plugin_types.each do |plugin_type|
|
243
|
-
PluginManager.find(plugin_type[1], "ddl").each do |ddlf|
|
244
|
-
pluginname = ddlf.gsub(/_#{plugin_type[1]}$/, "")
|
245
|
-
|
246
|
-
abort "Duplicate plugin name found, please specify a full path like agent/rpcutil" if pluginname == configuration[:target] && found_plugin_type
|
247
|
-
|
248
|
-
found_plugin_type = plugin_type[1] if pluginname == configuration[:target]
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
abort "Could not find a plugin named '%s' in any supported plugin type" % configuration[:target] unless found_plugin_type
|
253
|
-
ddl = load_plugin_ddl(configuration[:target], found_plugin_type)
|
254
|
-
end
|
255
|
-
|
256
|
-
if ddl
|
257
|
-
puts ddl.help(configuration[:rpctemplate])
|
258
|
-
else
|
259
|
-
abort "Could not find a '%s' plugin named '%s'" % configuration[:target].split("/")
|
260
|
-
end
|
261
|
-
|
262
|
-
else
|
263
|
-
puts "Please specify a plugin. Available plugins are:"
|
264
|
-
puts
|
265
|
-
|
266
|
-
load_errors = []
|
267
|
-
|
268
|
-
known_plugin_types.each do |plugin_type|
|
269
|
-
puts "%s:" % plugin_type[0]
|
139
|
+
def doc_command
|
140
|
+
puts "WARNING: mco plugin doc is deprecated, please use choria plugin doc"
|
270
141
|
|
271
|
-
|
272
|
-
begin
|
273
|
-
help = DDL.new(ddlf, plugin_type[1], false)
|
274
|
-
|
275
|
-
next unless help.client_activated?
|
276
|
-
|
277
|
-
help.loadddlfile
|
278
|
-
pluginname = ddlf.gsub(/_#{plugin_type[1]}$/, "")
|
279
|
-
puts " %-25s %s" % [pluginname, help.meta[:description]]
|
280
|
-
rescue => e
|
281
|
-
load_errors << [plugin_type[1], ddlf, e]
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
puts
|
286
|
-
end
|
287
|
-
|
288
|
-
unless load_errors.empty?
|
289
|
-
puts "Plugin Load Errors:"
|
290
|
-
|
291
|
-
load_errors.each do |e|
|
292
|
-
puts " %-25s %s" % ["#{e[0]}/#{e[1]}", Util.colorize(:yellow, e[2])]
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
142
|
+
exec("choria plugin doc %s" % [configuration[:target]])
|
296
143
|
end
|
297
144
|
|
298
145
|
# Creates the correct package plugin object.
|
@@ -345,7 +192,7 @@ mco plugin package [options] <directory>
|
|
345
192
|
# Return the name of the type of plugin as a string
|
346
193
|
def identify_plugin
|
347
194
|
plugintype = Dir.glob(File.join(configuration[:target], "*")).select do |file|
|
348
|
-
File.directory?(file) && file.match(/(connector|facts|registration|security|audit|pluginpackager|
|
195
|
+
File.directory?(file) && file.match(/(connector|facts|registration|security|audit|pluginpackager|discovery|validator)/)
|
349
196
|
end
|
350
197
|
|
351
198
|
raise "more than one plugin type detected in directory" if plugintype.size > 1
|
@@ -354,18 +201,6 @@ mco plugin package [options] <directory>
|
|
354
201
|
File.basename(plugintype[0])
|
355
202
|
end
|
356
203
|
|
357
|
-
# Load preset metadata values from config if they are present
|
358
|
-
# This makes it possible to override metadata values in a local
|
359
|
-
# client config file.
|
360
|
-
#
|
361
|
-
# Example : plugin.metadata.license = Apache 2
|
362
|
-
def load_plugin_config_values
|
363
|
-
config = Config.instance
|
364
|
-
[:pluginname, :description, :author, :license, :version, :url, :timeout].each do |confoption|
|
365
|
-
configuration[confoption] = config.pluginconf["metadata.#{confoption}"] unless configuration[confoption]
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
204
|
def main
|
370
205
|
abort "No action specified, please run 'mco help plugin' for help" unless configuration.include?(:action)
|
371
206
|
|
data/lib/mcollective/client.rb
CHANGED
@@ -150,7 +150,7 @@ module MCollective
|
|
150
150
|
# of the discovery being cancelled soon as it reached the
|
151
151
|
# requested limit of hosts
|
152
152
|
def discover(filter, timeout, limit=0)
|
153
|
-
@discoverer.discover(filter.merge("collective" => collective), timeout, limit)
|
153
|
+
@discoverer.discover(filter.merge("collective" => collective), timeout, limit, self)
|
154
154
|
end
|
155
155
|
|
156
156
|
# Send a request, performs the passed block for each response
|
data/lib/mcollective/config.rb
CHANGED
@@ -17,123 +17,132 @@ module MCollective
|
|
17
17
|
@configured = false
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def parse_config_file(configfile, libdirs) # rubocop:disable Metrics/MethodLength
|
21
|
+
File.readlines(configfile).each do |line|
|
22
|
+
# strip blank spaces, tabs etc off the end of all lines
|
23
|
+
line.gsub!(/\s*$/, "")
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
File.readlines(configfile).each do |line|
|
26
|
-
# strip blank spaces, tabs etc off the end of all lines
|
27
|
-
line.gsub!(/\s*$/, "")
|
25
|
+
next if line =~ /^#|^$/
|
26
|
+
next unless line =~ /(.+?)\s*=\s*(.+)/
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
key = $1.strip
|
29
|
+
val = $2
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
begin
|
32
|
+
case key
|
33
|
+
when "collectives"
|
34
|
+
@collectives = val.split(",").map(&:strip)
|
35
|
+
when "main_collective"
|
36
|
+
@main_collective = val
|
37
|
+
when "logfile"
|
38
|
+
@logfile = val
|
39
|
+
when "keeplogs"
|
40
|
+
@keeplogs = Integer(val)
|
41
|
+
when "max_log_size"
|
42
|
+
@max_log_size = Integer(val)
|
43
|
+
when "loglevel"
|
44
|
+
@loglevel = val
|
45
|
+
when "logfacility"
|
46
|
+
@logfacility = val
|
47
|
+
when "libdir"
|
48
|
+
paths = val.split(File::PATH_SEPARATOR)
|
49
|
+
paths.each do |path|
|
50
|
+
raise("libdir paths should be absolute paths but '%s' is relative" % path) unless Util.absolute_path?(path)
|
34
51
|
|
35
|
-
|
36
|
-
case key
|
37
|
-
when "collectives"
|
38
|
-
@collectives = val.split(",").map(&:strip)
|
39
|
-
when "main_collective"
|
40
|
-
@main_collective = val
|
41
|
-
when "logfile"
|
42
|
-
@logfile = val
|
43
|
-
when "keeplogs"
|
44
|
-
@keeplogs = Integer(val)
|
45
|
-
when "max_log_size"
|
46
|
-
@max_log_size = Integer(val)
|
47
|
-
when "loglevel"
|
48
|
-
@loglevel = val
|
49
|
-
when "logfacility"
|
50
|
-
@logfacility = val
|
51
|
-
when "libdir"
|
52
|
-
paths = val.split(File::PATH_SEPARATOR)
|
53
|
-
paths.each do |path|
|
54
|
-
raise("libdir paths should be absolute paths but '%s' is relative" % path) unless Util.absolute_path?(path)
|
55
|
-
|
56
|
-
libdirs << path
|
57
|
-
end
|
58
|
-
when "identity"
|
59
|
-
@identity = val
|
60
|
-
when "direct_addressing"
|
61
|
-
@direct_addressing = Util.str_to_bool(val)
|
62
|
-
when "direct_addressing_threshold"
|
63
|
-
@direct_addressing_threshold = Integer(val)
|
64
|
-
when "color"
|
65
|
-
@color = Util.str_to_bool(val)
|
66
|
-
when "daemonize"
|
67
|
-
@daemonize = Util.str_to_bool(val)
|
68
|
-
when "securityprovider"
|
69
|
-
@securityprovider = val.capitalize
|
70
|
-
when "factsource"
|
71
|
-
@factsource = val.capitalize
|
72
|
-
when "connector"
|
73
|
-
@connector = val.capitalize
|
74
|
-
when "classesfile"
|
75
|
-
@classesfile = val
|
76
|
-
when /^plugin.(.+)$/
|
77
|
-
@pluginconf[$1] = val
|
78
|
-
when "discovery_timeout"
|
79
|
-
@discovery_timeout = Integer(val)
|
80
|
-
when "publish_timeout"
|
81
|
-
@publish_timeout = Integer(val)
|
82
|
-
when "connection_timeout"
|
83
|
-
@connection_timeout = Integer(val)
|
84
|
-
when "rpcaudit"
|
85
|
-
@rpcaudit = Util.str_to_bool(val)
|
86
|
-
when "rpcauditprovider"
|
87
|
-
@rpcauditprovider = val.capitalize
|
88
|
-
when "rpcauthorization"
|
89
|
-
@rpcauthorization = Util.str_to_bool(val)
|
90
|
-
when "rpcauthprovider"
|
91
|
-
@rpcauthprovider = val.capitalize
|
92
|
-
when "rpclimitmethod"
|
93
|
-
@rpclimitmethod = val.to_sym
|
94
|
-
when "logger_type"
|
95
|
-
@logger_type = val
|
96
|
-
when "fact_cache_time"
|
97
|
-
@fact_cache_time = Integer(val)
|
98
|
-
when "ssl_cipher"
|
99
|
-
@ssl_cipher = val
|
100
|
-
when "threaded"
|
101
|
-
@threaded = Util.str_to_bool(val)
|
102
|
-
when "ttl"
|
103
|
-
@ttl = Integer(val)
|
104
|
-
when "default_discovery_options"
|
105
|
-
@default_discovery_options << val
|
106
|
-
when "default_discovery_method"
|
107
|
-
@default_discovery_method = val
|
108
|
-
when "soft_shutdown"
|
109
|
-
@soft_shutdown = Util.str_to_bool(val)
|
110
|
-
when "soft_shutdown_timeout"
|
111
|
-
@soft_shutdown_timeout = Integer(val)
|
112
|
-
when "activate_agents"
|
113
|
-
@activate_agents = Util.str_to_bool(val)
|
114
|
-
when "default_batch_size"
|
115
|
-
@default_batch_size = Integer(val)
|
116
|
-
when "default_batch_sleep_time"
|
117
|
-
@default_batch_sleep_time = Float(val)
|
118
|
-
else
|
119
|
-
# server config might now be choria config which will divirge from mcollective
|
120
|
-
# in time, so we only raise this error when it looks like we aren't loading
|
121
|
-
# a server config else we try our best to load as much as we can
|
122
|
-
raise("Unknown config parameter '#{key}'") unless configfile =~ /server/
|
52
|
+
libdirs << path
|
123
53
|
end
|
124
|
-
|
125
|
-
|
54
|
+
when "identity"
|
55
|
+
@identity = val
|
56
|
+
when "direct_addressing"
|
57
|
+
@direct_addressing = Util.str_to_bool(val)
|
58
|
+
when "direct_addressing_threshold"
|
59
|
+
@direct_addressing_threshold = Integer(val)
|
60
|
+
when "color"
|
61
|
+
@color = Util.str_to_bool(val)
|
62
|
+
when "daemonize"
|
63
|
+
@daemonize = Util.str_to_bool(val)
|
64
|
+
when "securityprovider"
|
65
|
+
@securityprovider = val.capitalize
|
66
|
+
when "factsource"
|
67
|
+
@factsource = val.capitalize
|
68
|
+
when "connector"
|
69
|
+
@connector = val.capitalize
|
70
|
+
when "classesfile"
|
71
|
+
@classesfile = val
|
72
|
+
when /^plugin.(.+)$/
|
73
|
+
@pluginconf[$1] = val
|
74
|
+
when "discovery_timeout"
|
75
|
+
@discovery_timeout = Integer(val)
|
76
|
+
when "publish_timeout"
|
77
|
+
@publish_timeout = Integer(val)
|
78
|
+
when "connection_timeout"
|
79
|
+
@connection_timeout = Integer(val)
|
80
|
+
when "rpcaudit"
|
81
|
+
@rpcaudit = Util.str_to_bool(val)
|
82
|
+
when "rpcauditprovider"
|
83
|
+
@rpcauditprovider = val.capitalize
|
84
|
+
when "rpcauthorization"
|
85
|
+
@rpcauthorization = Util.str_to_bool(val)
|
86
|
+
when "rpcauthprovider"
|
87
|
+
@rpcauthprovider = val.capitalize
|
88
|
+
when "rpclimitmethod"
|
89
|
+
@rpclimitmethod = val.to_sym
|
90
|
+
when "logger_type"
|
91
|
+
@logger_type = val
|
92
|
+
when "fact_cache_time"
|
93
|
+
@fact_cache_time = Integer(val)
|
94
|
+
when "ssl_cipher"
|
95
|
+
@ssl_cipher = val
|
96
|
+
when "threaded"
|
97
|
+
@threaded = Util.str_to_bool(val)
|
98
|
+
when "ttl"
|
99
|
+
@ttl = Integer(val)
|
100
|
+
when "default_discovery_options"
|
101
|
+
@default_discovery_options << val
|
102
|
+
when "default_discovery_method"
|
103
|
+
@default_discovery_method = val
|
104
|
+
when "soft_shutdown"
|
105
|
+
@soft_shutdown = Util.str_to_bool(val)
|
106
|
+
when "soft_shutdown_timeout"
|
107
|
+
@soft_shutdown_timeout = Integer(val)
|
108
|
+
when "activate_agents"
|
109
|
+
@activate_agents = Util.str_to_bool(val)
|
110
|
+
when "default_batch_size"
|
111
|
+
@default_batch_size = Integer(val)
|
112
|
+
when "default_batch_sleep_time"
|
113
|
+
@default_batch_sleep_time = Float(val)
|
114
|
+
else
|
115
|
+
# server config might now be choria config which will divirge from mcollective
|
116
|
+
# in time, so we only raise this error when it looks like we aren't loading
|
117
|
+
# a server config else we try our best to load as much as we can
|
118
|
+
raise("Unknown config parameter '#{key}'") unless configfile =~ /server/
|
126
119
|
end
|
120
|
+
rescue ArgumentError
|
121
|
+
raise("Could not parse value for configuration option '%s' with value '%s'" % [key, val])
|
127
122
|
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def loadconfig(configfile)
|
127
|
+
set_config_defaults(configfile)
|
128
|
+
|
129
|
+
if File.exist?(configfile)
|
130
|
+
libdirs = []
|
131
|
+
|
132
|
+
parse_config_file(configfile, libdirs)
|
128
133
|
|
129
134
|
read_plugin_config_dir("#{@configdir}/plugin.d")
|
130
135
|
|
131
|
-
|
136
|
+
parse_project_config(libdirs)
|
137
|
+
|
138
|
+
raise('Identities can only match /\w\.\-/') unless @identity =~ /^[\w.\-]+$/
|
139
|
+
|
140
|
+
check_deprecations
|
132
141
|
|
133
142
|
@configured = true
|
134
143
|
|
135
144
|
libdirs.each do |dir|
|
136
|
-
Log.debug("Cannot find libdir:
|
145
|
+
Log.debug("Cannot find libdir: %s" % dir) unless File.directory?(dir)
|
137
146
|
|
138
147
|
# remove the old one if it exists, we're moving it to the front
|
139
148
|
$LOAD_PATH.reject! { |elem| elem == dir }
|
@@ -154,6 +163,31 @@ module MCollective
|
|
154
163
|
end
|
155
164
|
end
|
156
165
|
|
166
|
+
def project_root
|
167
|
+
Dir.pwd
|
168
|
+
end
|
169
|
+
|
170
|
+
def parse_project_config(libdirs)
|
171
|
+
project_config_files(project_root).each do |pfile|
|
172
|
+
parse_config_file(pfile, libdirs)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def project_config_files(path)
|
177
|
+
paths = []
|
178
|
+
|
179
|
+
path = File.expand_path(path)
|
180
|
+
parent = File.expand_path("..", path)
|
181
|
+
|
182
|
+
paths << project_config_files(parent) if parent != path
|
183
|
+
|
184
|
+
config = File.join(path, "choria.conf")
|
185
|
+
|
186
|
+
paths << config if File.exist?(config)
|
187
|
+
|
188
|
+
paths.flatten
|
189
|
+
end
|
190
|
+
|
157
191
|
def set_config_defaults(configfile) # rubocop:disable Naming/AccessorMethodName
|
158
192
|
@subscribe = []
|
159
193
|
@pluginconf = {}
|
@@ -222,5 +256,13 @@ module MCollective
|
|
222
256
|
end
|
223
257
|
end
|
224
258
|
end
|
259
|
+
|
260
|
+
def check_deprecations
|
261
|
+
if @pluginconf["choria.use_srv_records"]
|
262
|
+
Log.warn("Configuration set 'choria.use_srv_records' which is deprecated in favor of 'choria.use_srv'.")
|
263
|
+
@pluginconf["choria.use_srv"] = @pluginconf["choria.use_srv_records"]
|
264
|
+
@pluginconf.delete("choria.use_srv_records")
|
265
|
+
end
|
266
|
+
end
|
225
267
|
end
|
226
268
|
end
|