choria-mcorpc-support 2.20.8 → 2.23.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mcollective.rb +1 -1
- data/lib/mcollective/agent/bolt_tasks.ddl +235 -0
- data/lib/mcollective/agent/bolt_tasks.json +347 -0
- data/lib/mcollective/agent/bolt_tasks.rb +176 -0
- data/lib/mcollective/agent/choria_util.ddl +152 -0
- data/lib/mcollective/agent/choria_util.json +244 -0
- data/lib/mcollective/agent/rpcutil.ddl +7 -3
- data/lib/mcollective/agent/rpcutil.json +333 -0
- data/lib/mcollective/agent/scout.ddl +169 -0
- data/lib/mcollective/agent/scout.json +224 -0
- data/lib/mcollective/agents.rb +7 -6
- data/lib/mcollective/aggregate.rb +4 -4
- data/lib/mcollective/aggregate/average.rb +2 -2
- data/lib/mcollective/aggregate/base.rb +2 -2
- data/lib/mcollective/aggregate/result.rb +3 -3
- data/lib/mcollective/aggregate/result/collection_result.rb +2 -2
- data/lib/mcollective/aggregate/result/numeric_result.rb +2 -2
- data/lib/mcollective/aggregate/sum.rb +2 -2
- data/lib/mcollective/aggregate/summary.rb +3 -4
- data/lib/mcollective/application.rb +57 -21
- data/lib/mcollective/application/choria.rb +249 -0
- data/lib/mcollective/application/completion.rb +6 -6
- data/lib/mcollective/application/describe_filter.rb +20 -20
- data/lib/mcollective/application/facts.rb +19 -11
- data/lib/mcollective/application/federation.rb +239 -0
- data/lib/mcollective/application/find.rb +4 -4
- data/lib/mcollective/application/help.rb +3 -3
- data/lib/mcollective/application/inventory.rb +3 -341
- data/lib/mcollective/application/ping.rb +3 -77
- data/lib/mcollective/application/playbook.rb +207 -0
- data/lib/mcollective/application/plugin.rb +106 -106
- data/lib/mcollective/application/rpc.rb +3 -108
- data/lib/mcollective/application/tasks.rb +416 -0
- data/lib/mcollective/applications.rb +11 -10
- data/lib/mcollective/audit/choria.rb +33 -0
- data/lib/mcollective/cache.rb +2 -4
- data/lib/mcollective/client.rb +11 -10
- data/lib/mcollective/config.rb +21 -34
- data/lib/mcollective/connector/base.rb +2 -1
- data/lib/mcollective/connector/nats.ddl +9 -0
- data/lib/mcollective/connector/nats.rb +450 -0
- data/lib/mcollective/data.rb +8 -3
- data/lib/mcollective/data/agent_data.rb +1 -1
- data/lib/mcollective/data/base.rb +6 -5
- data/lib/mcollective/data/bolt_task_data.ddl +90 -0
- data/lib/mcollective/data/bolt_task_data.rb +32 -0
- data/lib/mcollective/data/collective_data.rb +1 -1
- data/lib/mcollective/data/fact_data.rb +6 -6
- data/lib/mcollective/data/fstat_data.rb +2 -4
- data/lib/mcollective/data/result.rb +7 -2
- data/lib/mcollective/ddl/agentddl.rb +5 -17
- data/lib/mcollective/ddl/base.rb +11 -14
- data/lib/mcollective/discovery.rb +12 -26
- data/lib/mcollective/discovery/choria.ddl +11 -0
- data/lib/mcollective/discovery/choria.rb +223 -0
- data/lib/mcollective/discovery/flatfile.rb +7 -8
- data/lib/mcollective/discovery/mc.rb +2 -2
- data/lib/mcollective/discovery/stdin.rb +17 -18
- data/lib/mcollective/exceptions.rb +13 -0
- data/lib/mcollective/facts/base.rb +9 -9
- data/lib/mcollective/facts/yaml_facts.rb +12 -12
- data/lib/mcollective/generators.rb +3 -3
- data/lib/mcollective/generators/agent_generator.rb +3 -4
- data/lib/mcollective/generators/base.rb +14 -15
- data/lib/mcollective/generators/data_generator.rb +5 -6
- data/lib/mcollective/log.rb +2 -2
- data/lib/mcollective/logger/base.rb +3 -2
- data/lib/mcollective/logger/console_logger.rb +10 -10
- data/lib/mcollective/logger/file_logger.rb +7 -7
- data/lib/mcollective/logger/syslog_logger.rb +11 -15
- data/lib/mcollective/matcher.rb +14 -14
- data/lib/mcollective/matcher/parser.rb +31 -41
- data/lib/mcollective/matcher/scanner.rb +69 -74
- data/lib/mcollective/message.rb +10 -17
- data/lib/mcollective/monkey_patches.rb +2 -4
- data/lib/mcollective/optionparser.rb +1 -0
- data/lib/mcollective/pluginmanager.rb +3 -5
- data/lib/mcollective/pluginpackager.rb +1 -3
- data/lib/mcollective/pluginpackager/agent_definition.rb +10 -11
- data/lib/mcollective/pluginpackager/forge_packager.rb +7 -9
- data/lib/mcollective/pluginpackager/standard_definition.rb +1 -2
- data/lib/mcollective/registration/base.rb +18 -16
- data/lib/mcollective/rpc.rb +2 -4
- data/lib/mcollective/rpc/actionrunner.rb +16 -18
- data/lib/mcollective/rpc/agent.rb +26 -43
- data/lib/mcollective/rpc/audit.rb +1 -0
- data/lib/mcollective/rpc/client.rb +67 -85
- data/lib/mcollective/rpc/helpers.rb +55 -62
- data/lib/mcollective/rpc/progress.rb +2 -2
- data/lib/mcollective/rpc/reply.rb +17 -19
- data/lib/mcollective/rpc/request.rb +7 -5
- data/lib/mcollective/rpc/result.rb +6 -8
- data/lib/mcollective/rpc/stats.rb +49 -58
- data/lib/mcollective/security/base.rb +29 -36
- data/lib/mcollective/security/choria.rb +765 -0
- data/lib/mcollective/shell.rb +9 -4
- data/lib/mcollective/signer/base.rb +28 -0
- data/lib/mcollective/signer/choria.rb +185 -0
- data/lib/mcollective/ssl.rb +8 -6
- data/lib/mcollective/util.rb +58 -55
- data/lib/mcollective/util/bolt_support.rb +176 -0
- data/lib/mcollective/util/bolt_support/plan_runner.rb +167 -0
- data/lib/mcollective/util/bolt_support/task_result.rb +94 -0
- data/lib/mcollective/util/bolt_support/task_results.rb +128 -0
- data/lib/mcollective/util/choria.rb +1103 -0
- data/lib/mcollective/util/indifferent_hash.rb +12 -0
- data/lib/mcollective/util/natswrapper.rb +242 -0
- data/lib/mcollective/util/playbook.rb +435 -0
- data/lib/mcollective/util/playbook/data_stores.rb +201 -0
- data/lib/mcollective/util/playbook/data_stores/base.rb +99 -0
- data/lib/mcollective/util/playbook/data_stores/consul_data_store.rb +88 -0
- data/lib/mcollective/util/playbook/data_stores/environment_data_store.rb +33 -0
- data/lib/mcollective/util/playbook/data_stores/etcd_data_store.rb +42 -0
- data/lib/mcollective/util/playbook/data_stores/file_data_store.rb +106 -0
- data/lib/mcollective/util/playbook/data_stores/shell_data_store.rb +103 -0
- data/lib/mcollective/util/playbook/inputs.rb +265 -0
- data/lib/mcollective/util/playbook/nodes.rb +207 -0
- data/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb +86 -0
- data/lib/mcollective/util/playbook/nodes/pql_nodes.rb +40 -0
- data/lib/mcollective/util/playbook/nodes/shell_nodes.rb +55 -0
- data/lib/mcollective/util/playbook/nodes/terraform_nodes.rb +65 -0
- data/lib/mcollective/util/playbook/nodes/yaml_nodes.rb +47 -0
- data/lib/mcollective/util/playbook/playbook_logger.rb +47 -0
- data/lib/mcollective/util/playbook/puppet_logger.rb +51 -0
- data/lib/mcollective/util/playbook/report.rb +152 -0
- data/lib/mcollective/util/playbook/task_result.rb +55 -0
- data/lib/mcollective/util/playbook/tasks.rb +196 -0
- data/lib/mcollective/util/playbook/tasks/base.rb +45 -0
- data/lib/mcollective/util/playbook/tasks/graphite_event_task.rb +64 -0
- data/lib/mcollective/util/playbook/tasks/mcollective_task.rb +356 -0
- data/lib/mcollective/util/playbook/tasks/shell_task.rb +93 -0
- data/lib/mcollective/util/playbook/tasks/slack_task.rb +105 -0
- data/lib/mcollective/util/playbook/tasks/webhook_task.rb +136 -0
- data/lib/mcollective/util/playbook/template_util.rb +98 -0
- data/lib/mcollective/util/playbook/uses.rb +169 -0
- data/lib/mcollective/util/tasks_support.rb +733 -0
- data/lib/mcollective/util/tasks_support/cli.rb +260 -0
- data/lib/mcollective/util/tasks_support/default_formatter.rb +138 -0
- data/lib/mcollective/util/tasks_support/json_formatter.rb +108 -0
- data/lib/mcollective/validator.rb +8 -3
- data/lib/mcollective/validator/bolt_task_name_validator.ddl +7 -0
- data/lib/mcollective/validator/bolt_task_name_validator.rb +11 -0
- data/lib/mcollective/validator/length_validator.rb +1 -3
- data/lib/mcollective/validator/typecheck_validator.rb +4 -0
- metadata +67 -4
@@ -11,33 +11,31 @@ module MCollective
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Scans the input string and identifies single language tokens
|
14
|
-
def get_token
|
15
|
-
if @token_index >= @arguments.size
|
16
|
-
return nil
|
17
|
-
end
|
14
|
+
def get_token # rubocop:disable Naming/AccessorMethodName
|
15
|
+
return nil if @token_index >= @arguments.size
|
18
16
|
|
19
17
|
case @arguments[@token_index]
|
20
18
|
when "("
|
21
|
-
|
19
|
+
["(", "("]
|
22
20
|
|
23
21
|
when ")"
|
24
|
-
|
22
|
+
[")", ")"]
|
25
23
|
|
26
24
|
when "n"
|
27
25
|
if (@arguments[@token_index + 1] == "o") && (@arguments[@token_index + 2] == "t") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
|
28
26
|
@token_index += 2
|
29
|
-
|
27
|
+
["not", "not"]
|
30
28
|
else
|
31
29
|
gen_statement
|
32
30
|
end
|
33
31
|
|
34
32
|
when "!"
|
35
|
-
|
33
|
+
["not", "not"]
|
36
34
|
|
37
35
|
when "a"
|
38
36
|
if (@arguments[@token_index + 1] == "n") && (@arguments[@token_index + 2] == "d") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
|
39
37
|
@token_index += 2
|
40
|
-
|
38
|
+
["and", "and"]
|
41
39
|
else
|
42
40
|
gen_statement
|
43
41
|
end
|
@@ -45,13 +43,13 @@ module MCollective
|
|
45
43
|
when "o"
|
46
44
|
if (@arguments[@token_index + 1] == "r") && ((@arguments[@token_index + 2] == " ") || (@arguments[@token_index + 2] == "("))
|
47
45
|
@token_index += 1
|
48
|
-
|
46
|
+
["or", "or"]
|
49
47
|
else
|
50
48
|
gen_statement
|
51
49
|
end
|
52
50
|
|
53
51
|
when " "
|
54
|
-
|
52
|
+
[" ", " "]
|
55
53
|
|
56
54
|
else
|
57
55
|
gen_statement
|
@@ -59,21 +57,24 @@ module MCollective
|
|
59
57
|
end
|
60
58
|
|
61
59
|
private
|
60
|
+
|
62
61
|
# Helper generates a statement token
|
63
|
-
def gen_statement
|
62
|
+
def gen_statement # rubocop:disable Metrics/MethodLength
|
64
63
|
func = false
|
65
64
|
current_token_value = ""
|
66
65
|
j = @token_index
|
67
66
|
escaped = false
|
68
67
|
|
69
68
|
begin
|
70
|
-
|
71
|
-
|
69
|
+
case @arguments[j]
|
70
|
+
when "/"
|
71
|
+
loop do
|
72
72
|
current_token_value << @arguments[j]
|
73
73
|
j += 1
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
break if (j >= @arguments.size) || (@arguments[j] =~ /\s/)
|
75
|
+
end
|
76
|
+
when /=|<|>/
|
77
|
+
while @arguments[j] !~ /=|<|>/
|
77
78
|
current_token_value << @arguments[j]
|
78
79
|
j += 1
|
79
80
|
end
|
@@ -82,27 +83,28 @@ module MCollective
|
|
82
83
|
j += 1
|
83
84
|
|
84
85
|
if @arguments[j] == "/"
|
85
|
-
|
86
|
+
loop do
|
86
87
|
current_token_value << @arguments[j]
|
87
88
|
j += 1
|
88
89
|
if @arguments[j] == "/"
|
89
90
|
current_token_value << "/"
|
90
91
|
break
|
91
92
|
end
|
92
|
-
|
93
|
+
break if (j >= @arguments.size) || (@arguments[j] =~ /\//)
|
94
|
+
end
|
93
95
|
while (j < @arguments.size) && ((@arguments[j] != " ") && (@arguments[j] != ")"))
|
94
96
|
current_token_value << @arguments[j]
|
95
97
|
j += 1
|
96
98
|
end
|
97
99
|
end
|
98
100
|
else
|
99
|
-
|
101
|
+
loop do
|
100
102
|
# Identify and tokenize regular expressions by ignoring everything between /'s
|
101
|
-
if @arguments[j] ==
|
102
|
-
current_token_value <<
|
103
|
+
if @arguments[j] == "/"
|
104
|
+
current_token_value << "/"
|
103
105
|
j += 1
|
104
|
-
while
|
105
|
-
if
|
106
|
+
while j < @arguments.size && @arguments[j] != "/"
|
107
|
+
if @arguments[j] == '\\' # rubocop:disable Metrics/BlockNesting
|
106
108
|
# eat the escape char
|
107
109
|
current_token_value << @arguments[j]
|
108
110
|
j += 1
|
@@ -116,7 +118,8 @@ module MCollective
|
|
116
118
|
break
|
117
119
|
end
|
118
120
|
|
119
|
-
|
121
|
+
case @arguments[j]
|
122
|
+
when "("
|
120
123
|
func = true
|
121
124
|
|
122
125
|
current_token_value << @arguments[j]
|
@@ -124,29 +127,29 @@ module MCollective
|
|
124
127
|
|
125
128
|
while j < @arguments.size
|
126
129
|
current_token_value << @arguments[j]
|
127
|
-
if @arguments[j] ==
|
130
|
+
if @arguments[j] == ")" # rubocop:disable Metrics/BlockNesting
|
128
131
|
j += 1
|
129
132
|
break
|
130
133
|
end
|
131
134
|
j += 1
|
132
135
|
end
|
133
|
-
|
136
|
+
when '"', "'"
|
134
137
|
escaped = true
|
135
138
|
escaped_with = @arguments[j]
|
136
139
|
|
137
140
|
j += 1 # step over first " or '
|
138
141
|
@white_spaces += 1
|
139
142
|
# identified "..." or '...'
|
143
|
+
# rubocop:disable Metrics/BlockNesting
|
140
144
|
while j < @arguments.size
|
141
|
-
|
145
|
+
case @arguments[j]
|
146
|
+
when '\\'
|
142
147
|
# eat the escape char but don't add it to the token, or we
|
143
148
|
# end up with \\\"
|
144
149
|
j += 1
|
145
150
|
@white_spaces += 1
|
146
|
-
unless j < @arguments.size
|
147
|
-
|
148
|
-
end
|
149
|
-
elsif @arguments[j] == escaped_with
|
151
|
+
break unless j < @arguments.size
|
152
|
+
when escaped_with
|
150
153
|
j += 1
|
151
154
|
@white_spaces += 1
|
152
155
|
break
|
@@ -154,24 +157,22 @@ module MCollective
|
|
154
157
|
current_token_value << @arguments[j]
|
155
158
|
j += 1
|
156
159
|
end
|
160
|
+
# rubocop:enable Metrics/BlockNesting
|
157
161
|
else
|
158
162
|
current_token_value << @arguments[j]
|
159
163
|
j += 1
|
160
164
|
end
|
161
165
|
|
162
|
-
if
|
163
|
-
break if(is_klass?(j) && !(@arguments[j-1] =~ /=|<|>/))
|
164
|
-
end
|
166
|
+
break if @arguments[j] == " " && (is_klass?(j) && @arguments[j - 1] !~ /=|<|>/)
|
165
167
|
|
166
|
-
if
|
167
|
-
|
168
|
-
j = index
|
169
|
-
end
|
168
|
+
if (@arguments[j] == " ") && (@seperation_counter < 2) && !current_token_value.match(/^.+(=|<|>).+$/) && (index = lookahead(j))
|
169
|
+
j = index
|
170
170
|
end
|
171
|
-
|
171
|
+
break if (j >= @arguments.size) || (@arguments[j] =~ /\s|\)/)
|
172
|
+
end
|
172
173
|
@seperation_counter = 0
|
173
174
|
end
|
174
|
-
rescue Exception => e
|
175
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
175
176
|
raise "An exception was raised while trying to tokenize '#{current_token_value} - #{e}'"
|
176
177
|
end
|
177
178
|
|
@@ -180,61 +181,55 @@ module MCollective
|
|
180
181
|
|
181
182
|
# bar(
|
182
183
|
if current_token_value.match(/.+?\($/)
|
183
|
-
|
184
|
+
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
184
185
|
# /foo/=bar
|
185
186
|
elsif current_token_value.match(/^\/.+?\/(<|>|=).+/)
|
186
|
-
|
187
|
+
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
187
188
|
elsif current_token_value.match(/^.+?\/(<|>|=).+/)
|
188
|
-
|
189
|
-
|
190
|
-
if
|
191
|
-
|
192
|
-
|
193
|
-
return "fstatement", current_token_value
|
194
|
-
else
|
195
|
-
return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
|
196
|
-
end
|
189
|
+
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
190
|
+
elsif func
|
191
|
+
if current_token_value.match(/^.+?\((\s*(')[^']*(')\s*(,\s*(')[^']*('))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/) ||
|
192
|
+
current_token_value.match(/^.+?\((\s*(")[^"]*(")\s*(,\s*(")[^"]*("))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/)
|
193
|
+
["fstatement", current_token_value]
|
197
194
|
else
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
207
|
-
return "bad_token", [@token_index - current_token_value.size + 1, @token_index] if slash_err
|
208
|
-
return "statement", current_token_value
|
195
|
+
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
196
|
+
end
|
197
|
+
else
|
198
|
+
return "statement", current_token_value if escaped
|
199
|
+
|
200
|
+
slash_err = false
|
201
|
+
current_token_value.split("").each do |c|
|
202
|
+
slash_err = !slash_err if c == "/"
|
209
203
|
end
|
204
|
+
return "bad_token", [@token_index - current_token_value.size + 1, @token_index] if slash_err
|
205
|
+
|
206
|
+
["statement", current_token_value]
|
210
207
|
end
|
211
208
|
end
|
212
209
|
|
213
210
|
# Deal with special puppet class statement
|
214
|
-
def is_klass?(
|
215
|
-
while
|
216
|
-
j += 1
|
217
|
-
end
|
211
|
+
def is_klass?(klass)
|
212
|
+
klass += 1 while klass < @arguments.size && @arguments[klass] == " "
|
218
213
|
|
219
|
-
if @arguments[
|
220
|
-
|
214
|
+
if @arguments[klass] =~ /=|<|>/
|
215
|
+
false
|
221
216
|
else
|
222
|
-
|
217
|
+
true
|
223
218
|
end
|
224
219
|
end
|
225
220
|
|
226
221
|
# Eat spaces while looking for the next comparison symbol
|
227
222
|
def lookahead(index)
|
228
223
|
index += 1
|
229
|
-
while
|
224
|
+
while index <= @arguments.size
|
230
225
|
@white_spaces += 1
|
231
|
-
unless
|
232
|
-
@seperation_counter +=1
|
226
|
+
unless @arguments[index] =~ /\s/
|
227
|
+
@seperation_counter += 1
|
233
228
|
return index
|
234
229
|
end
|
235
230
|
index += 1
|
236
231
|
end
|
237
|
-
|
232
|
+
nil
|
238
233
|
end
|
239
234
|
end
|
240
235
|
end
|
data/lib/mcollective/message.rb
CHANGED
@@ -2,8 +2,7 @@ module MCollective
|
|
2
2
|
# container for a message, its headers, agent, collective and other meta data
|
3
3
|
class Message
|
4
4
|
attr_reader :message, :request, :validated, :msgtime, :payload, :type, :expected_msgid, :reply_to
|
5
|
-
attr_accessor :headers, :agent, :collective, :filter
|
6
|
-
attr_accessor :requestid, :discovered_hosts, :options, :ttl
|
5
|
+
attr_accessor :headers, :agent, :collective, :filter, :requestid, :discovered_hosts, :options, :ttl
|
7
6
|
|
8
7
|
VALIDTYPES = [:message, :request, :direct_request, :reply].freeze
|
9
8
|
|
@@ -79,9 +78,7 @@ module MCollective
|
|
79
78
|
if type == :direct_request
|
80
79
|
raise "Direct requests is not enabled using the direct_addressing config option" unless Config.instance.direct_addressing
|
81
80
|
|
82
|
-
unless @discovered_hosts && !@discovered_hosts.empty?
|
83
|
-
raise "Can only set type to :direct_request if discovered_hosts have been set"
|
84
|
-
end
|
81
|
+
raise "Can only set type to :direct_request if discovered_hosts have been set" unless @discovered_hosts && !@discovered_hosts.empty?
|
85
82
|
|
86
83
|
# clear out the filter, custom discovery sources might interpret the filters
|
87
84
|
# different than the remote mcollectived and in directed mode really the only
|
@@ -109,6 +106,7 @@ module MCollective
|
|
109
106
|
# at us.
|
110
107
|
def expected_msgid=(msgid)
|
111
108
|
raise "Can only store the expected msgid for reply messages" unless @type == :reply
|
109
|
+
|
112
110
|
@expected_msgid = msgid
|
113
111
|
end
|
114
112
|
|
@@ -132,7 +130,7 @@ module MCollective
|
|
132
130
|
|
133
131
|
def description
|
134
132
|
cid = ""
|
135
|
-
cid += payload[:callerid]
|
133
|
+
cid += "#{payload[:callerid]}@" if payload.include?(:callerid)
|
136
134
|
cid += payload[:senderid]
|
137
135
|
|
138
136
|
"#{requestid} for agent '#{agent}' in collective '#{collective}' from #{cid}"
|
@@ -163,6 +161,7 @@ module MCollective
|
|
163
161
|
compound_filter.each do |filter|
|
164
162
|
filter.each do |statement|
|
165
163
|
next unless statement["fstatement"]
|
164
|
+
|
166
165
|
functionname = statement["fstatement"]["name"]
|
167
166
|
pluginname = Data.pluginname(functionname)
|
168
167
|
value = statement["fstatement"]["value"]
|
@@ -175,9 +174,7 @@ module MCollective
|
|
175
174
|
|
176
175
|
Data.ddl_validate(ddl, statement["fstatement"]["params"])
|
177
176
|
|
178
|
-
unless value && Data.ddl_has_output?(ddl, value)
|
179
|
-
raise(DDLValidationError, "Data plugin '%s()' does not return a '%s' value" % [functionname, value])
|
180
|
-
end
|
177
|
+
raise(DDLValidationError, "Data plugin '%s()' does not return a '%s' value" % [functionname, value]) unless value && Data.ddl_has_output?(ddl, value)
|
181
178
|
end
|
182
179
|
end
|
183
180
|
end
|
@@ -194,15 +191,15 @@ module MCollective
|
|
194
191
|
else
|
195
192
|
# We're in the client, log and carry on as best we can
|
196
193
|
|
197
|
-
#
|
194
|
+
# NOTE: mc_sender is unverified. The verified identity is in the
|
198
195
|
# payload we just failed to decode
|
199
196
|
Log.warn("Failed to decode a message from '#{headers['mc_sender']}': #{e}")
|
200
197
|
return
|
201
198
|
end
|
202
199
|
end
|
203
200
|
|
204
|
-
if type == :request
|
205
|
-
raise "callerid in request is not valid, surpressing reply to potentially forged request"
|
201
|
+
if type == :request && !PluginManager["security_plugin"].valid_callerid?(payload[:callerid])
|
202
|
+
raise "callerid in request is not valid, surpressing reply to potentially forged request"
|
206
203
|
end
|
207
204
|
|
208
205
|
[:collective, :agent, :filter, :requestid, :ttl, :msgtime].each do |prop|
|
@@ -216,11 +213,7 @@ module MCollective
|
|
216
213
|
|
217
214
|
msg_age = Time.now.utc.to_i - msgtime
|
218
215
|
|
219
|
-
if msg_age > ttl
|
220
|
-
PluginManager["global_stats"].ttlexpired
|
221
|
-
raise(MsgTTLExpired, "Message #{description} created at #{msgtime} is #{msg_age} seconds old, TTL is #{ttl}. Rejecting message.")
|
222
|
-
end
|
223
|
-
|
216
|
+
raise(MsgTTLExpired, "Message #{description} created at #{msgtime} is #{msg_age} seconds old, TTL is #{ttl}. Rejecting message.") if msg_age > ttl
|
224
217
|
raise(NotTargettedAtUs, "Message #{description} does not pass filters. Ignoring message.") unless PluginManager["security_plugin"].validate_filter?(payload[:filter])
|
225
218
|
|
226
219
|
@validated = true
|
@@ -67,8 +67,8 @@ class String
|
|
67
67
|
unless method_defined?(:bytes)
|
68
68
|
def bytes(&block)
|
69
69
|
# This should not be necessary, really ...
|
70
|
-
require "enumerator"
|
71
70
|
return to_enum(:each_byte) unless block_given?
|
71
|
+
|
72
72
|
each_byte(&block)
|
73
73
|
end
|
74
74
|
end
|
@@ -141,9 +141,7 @@ class OpenSSL::SSL::SSLContext # rubocop:disable Style/ClassAndModuleChildren
|
|
141
141
|
end
|
142
142
|
|
143
143
|
# ruby 1.8.5 doesn't define this constant, but has it on by default
|
144
|
-
if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
|
145
|
-
DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
|
146
|
-
end
|
144
|
+
DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
|
147
145
|
|
148
146
|
DEFAULT_PARAMS[:ciphers] << ":!SSLv2" if DEFAULT_PARAMS[:ciphers]
|
149
147
|
|
@@ -155,6 +155,7 @@ module MCollective
|
|
155
155
|
|
156
156
|
@parser.on("--dm", "--disc-method METHOD", "Which discovery method to use") do |v|
|
157
157
|
raise "Discovery method is already set by a competing option" if @options[:discovery_method] && @options[:discovery_method] != v
|
158
|
+
|
158
159
|
@options[:discovery_method] = v
|
159
160
|
end
|
160
161
|
|
@@ -91,7 +91,7 @@ module MCollective
|
|
91
91
|
|
92
92
|
# use eval to create an instance of a class
|
93
93
|
def self.create_instance(klass)
|
94
|
-
eval("#{klass}.new") # rubocop:disable Security/Eval
|
94
|
+
eval("#{klass}.new") # rubocop:disable Security/Eval, Style/EvalWithLocation
|
95
95
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
96
96
|
raise("Could not create instance of plugin #{klass}: #{e}")
|
97
97
|
end
|
@@ -146,9 +146,7 @@ module MCollective
|
|
146
146
|
extension = ".#{extension}" unless extension =~ /^\./
|
147
147
|
|
148
148
|
klasses = find(type, extension).map do |plugin|
|
149
|
-
if block_given?
|
150
|
-
next unless yield(plugin)
|
151
|
-
end
|
149
|
+
next if block_given? && !yield(plugin)
|
152
150
|
|
153
151
|
"%s::%s::%s" % ["MCollective", type.capitalize, plugin.capitalize]
|
154
152
|
end.compact
|
@@ -159,7 +157,7 @@ module MCollective
|
|
159
157
|
# Loads a class from file by doing some simple search/replace
|
160
158
|
# on class names and then doing a require.
|
161
159
|
def self.loadclass(klass, squash_failures=false)
|
162
|
-
fname = klass.gsub(
|
160
|
+
fname = "#{klass.gsub('::', '/').downcase}.rb"
|
163
161
|
|
164
162
|
Log.debug("Loading #{klass} from #{fname}")
|
165
163
|
|
@@ -84,9 +84,7 @@ module MCollective
|
|
84
84
|
|
85
85
|
# Return the path to a plugin's core directories
|
86
86
|
def self.get_plugin_path(target)
|
87
|
-
if File.exist?(File.join(target, "lib", "mcollective"))
|
88
|
-
return File.join(target, "lib", "mcollective")
|
89
|
-
end
|
87
|
+
return File.join(target, "lib", "mcollective") if File.exist?(File.join(target, "lib", "mcollective"))
|
90
88
|
|
91
89
|
target
|
92
90
|
end
|
@@ -2,8 +2,7 @@ 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, :revision, :preinstall
|
6
|
-
attr_accessor :plugintype, :dependencies, :postinstall, :mcname, :mcversion
|
5
|
+
attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :revision, :preinstall, :plugintype, :dependencies, :postinstall, :mcname, :mcversion
|
7
6
|
|
8
7
|
def initialize(configuration, mcdependency, plugintype)
|
9
8
|
@plugintype = plugintype
|
@@ -20,7 +19,9 @@ module MCollective
|
|
20
19
|
@mcversion = mcdependency[:mcversion] || mcversion
|
21
20
|
@metadata[:version] = (configuration[:version] || @metadata[:version])
|
22
21
|
@dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
|
22
|
+
@agent_name = @metadata[:name].downcase
|
23
23
|
@metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
24
|
+
|
24
25
|
identify_packages
|
25
26
|
end
|
26
27
|
|
@@ -51,18 +52,18 @@ module MCollective
|
|
51
52
|
agent[:files] = (Dir.glob(File.join(agentdir, "**", "**")) - ddls)
|
52
53
|
agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision}
|
53
54
|
|
54
|
-
if @metadata[:provider] == "external"
|
55
|
-
agent[:executable_files] << File.join(agentdir, @metadata[:name])
|
56
|
-
end
|
55
|
+
agent[:executable_files] << File.join(agentdir, @agent_name) if @metadata[:provider] == "external"
|
57
56
|
|
58
57
|
agent
|
59
58
|
end
|
60
59
|
|
61
60
|
# Obtain client package files and dependencies.
|
62
61
|
def client
|
63
|
-
client = {
|
64
|
-
|
65
|
-
|
62
|
+
client = {
|
63
|
+
:files => [],
|
64
|
+
:dependencies => @dependencies.clone,
|
65
|
+
:description => "Client plugin for #{@metadata[:name]}"
|
66
|
+
}
|
66
67
|
|
67
68
|
clientdir = File.join(@path, "application")
|
68
69
|
aggregatedir = File.join(@path, "aggregate")
|
@@ -91,9 +92,7 @@ module MCollective
|
|
91
92
|
end
|
92
93
|
|
93
94
|
# We fail if there is no ddl file present
|
94
|
-
if common[:files].grep(/^.*\.ddl$/).empty?
|
95
|
-
raise "cannot create package - No ddl file found in #{File.join(@path, 'agent')}"
|
96
|
-
end
|
95
|
+
raise "cannot create package - No ddl file found in #{File.join(@path, 'agent')}" if common[:files].grep(/^.*\.ddl$/).empty?
|
97
96
|
|
98
97
|
common[:files].uniq!
|
99
98
|
|