choria-mcorpc-support 2.23.0.pre → 2.24.0
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/bolt_tasks.ddl +18 -0
- data/lib/mcollective/agent/bolt_tasks.json +18 -0
- data/lib/mcollective/agent/bolt_tasks.rb +4 -2
- data/lib/mcollective/agent/rpcutil.ddl +2 -2
- data/lib/mcollective/agent/rpcutil.json +2 -2
- data/lib/mcollective/application/choria.rb +3 -63
- data/lib/mcollective/application/facts.rb +2 -67
- data/lib/mcollective/application/federation.rb +1 -3
- data/lib/mcollective/application/find.rb +1 -1
- data/lib/mcollective/application/ping.rb +31 -3
- data/lib/mcollective/application/plugin.rb +2 -15
- data/lib/mcollective/application/tasks.rb +9 -0
- data/lib/mcollective/client.rb +1 -1
- data/lib/mcollective/config.rb +135 -103
- data/lib/mcollective/discovery.rb +12 -65
- 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 +73 -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/message.rb +0 -24
- data/lib/mcollective/optionparser.rb +2 -2
- data/lib/mcollective/pluginpackager/forge_packager.rb +1 -1
- data/lib/mcollective/rpc/client.rb +6 -4
- data/lib/mcollective/security/base.rb +1 -37
- data/lib/mcollective/util.rb +23 -31
- data/lib/mcollective/util/choria.rb +0 -157
- data/lib/mcollective/util/tasks_support.rb +22 -3
- metadata +11 -29
- data/lib/mcollective/application/describe_filter.rb +0 -87
- 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/data_generator.rb +0 -50
- data/lib/mcollective/generators/templates/data_input_snippet.erb +0 -7
- data/lib/mcollective/matcher.rb +0 -220
- data/lib/mcollective/matcher/parser.rb +0 -118
- data/lib/mcollective/matcher/scanner.rb +0 -236
@@ -1,236 +0,0 @@
|
|
1
|
-
module MCollective
|
2
|
-
module Matcher
|
3
|
-
class Scanner
|
4
|
-
attr_accessor :arguments, :token_index
|
5
|
-
|
6
|
-
def initialize(arguments)
|
7
|
-
@token_index = 0
|
8
|
-
@arguments = arguments.split("")
|
9
|
-
@seperation_counter = 0
|
10
|
-
@white_spaces = 0
|
11
|
-
end
|
12
|
-
|
13
|
-
# Scans the input string and identifies single language tokens
|
14
|
-
def get_token # rubocop:disable Naming/AccessorMethodName
|
15
|
-
return nil if @token_index >= @arguments.size
|
16
|
-
|
17
|
-
case @arguments[@token_index]
|
18
|
-
when "("
|
19
|
-
["(", "("]
|
20
|
-
|
21
|
-
when ")"
|
22
|
-
[")", ")"]
|
23
|
-
|
24
|
-
when "n"
|
25
|
-
if (@arguments[@token_index + 1] == "o") && (@arguments[@token_index + 2] == "t") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
|
26
|
-
@token_index += 2
|
27
|
-
["not", "not"]
|
28
|
-
else
|
29
|
-
gen_statement
|
30
|
-
end
|
31
|
-
|
32
|
-
when "!"
|
33
|
-
["not", "not"]
|
34
|
-
|
35
|
-
when "a"
|
36
|
-
if (@arguments[@token_index + 1] == "n") && (@arguments[@token_index + 2] == "d") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
|
37
|
-
@token_index += 2
|
38
|
-
["and", "and"]
|
39
|
-
else
|
40
|
-
gen_statement
|
41
|
-
end
|
42
|
-
|
43
|
-
when "o"
|
44
|
-
if (@arguments[@token_index + 1] == "r") && ((@arguments[@token_index + 2] == " ") || (@arguments[@token_index + 2] == "("))
|
45
|
-
@token_index += 1
|
46
|
-
["or", "or"]
|
47
|
-
else
|
48
|
-
gen_statement
|
49
|
-
end
|
50
|
-
|
51
|
-
when " "
|
52
|
-
[" ", " "]
|
53
|
-
|
54
|
-
else
|
55
|
-
gen_statement
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
# Helper generates a statement token
|
62
|
-
def gen_statement # rubocop:disable Metrics/MethodLength
|
63
|
-
func = false
|
64
|
-
current_token_value = ""
|
65
|
-
j = @token_index
|
66
|
-
escaped = false
|
67
|
-
|
68
|
-
begin
|
69
|
-
case @arguments[j]
|
70
|
-
when "/"
|
71
|
-
loop do
|
72
|
-
current_token_value << @arguments[j]
|
73
|
-
j += 1
|
74
|
-
break if (j >= @arguments.size) || (@arguments[j] =~ /\s/)
|
75
|
-
end
|
76
|
-
when /=|<|>/
|
77
|
-
while @arguments[j] !~ /=|<|>/
|
78
|
-
current_token_value << @arguments[j]
|
79
|
-
j += 1
|
80
|
-
end
|
81
|
-
|
82
|
-
current_token_value << @arguments[j]
|
83
|
-
j += 1
|
84
|
-
|
85
|
-
if @arguments[j] == "/"
|
86
|
-
loop do
|
87
|
-
current_token_value << @arguments[j]
|
88
|
-
j += 1
|
89
|
-
if @arguments[j] == "/"
|
90
|
-
current_token_value << "/"
|
91
|
-
break
|
92
|
-
end
|
93
|
-
break if (j >= @arguments.size) || (@arguments[j] =~ /\//)
|
94
|
-
end
|
95
|
-
while (j < @arguments.size) && ((@arguments[j] != " ") && (@arguments[j] != ")"))
|
96
|
-
current_token_value << @arguments[j]
|
97
|
-
j += 1
|
98
|
-
end
|
99
|
-
end
|
100
|
-
else
|
101
|
-
loop do
|
102
|
-
# Identify and tokenize regular expressions by ignoring everything between /'s
|
103
|
-
if @arguments[j] == "/"
|
104
|
-
current_token_value << "/"
|
105
|
-
j += 1
|
106
|
-
while j < @arguments.size && @arguments[j] != "/"
|
107
|
-
if @arguments[j] == '\\' # rubocop:disable Metrics/BlockNesting
|
108
|
-
# eat the escape char
|
109
|
-
current_token_value << @arguments[j]
|
110
|
-
j += 1
|
111
|
-
escaped = true
|
112
|
-
end
|
113
|
-
|
114
|
-
current_token_value << @arguments[j]
|
115
|
-
j += 1
|
116
|
-
end
|
117
|
-
current_token_value << @arguments[j] if @arguments[j]
|
118
|
-
break
|
119
|
-
end
|
120
|
-
|
121
|
-
case @arguments[j]
|
122
|
-
when "("
|
123
|
-
func = true
|
124
|
-
|
125
|
-
current_token_value << @arguments[j]
|
126
|
-
j += 1
|
127
|
-
|
128
|
-
while j < @arguments.size
|
129
|
-
current_token_value << @arguments[j]
|
130
|
-
if @arguments[j] == ")" # rubocop:disable Metrics/BlockNesting
|
131
|
-
j += 1
|
132
|
-
break
|
133
|
-
end
|
134
|
-
j += 1
|
135
|
-
end
|
136
|
-
when '"', "'"
|
137
|
-
escaped = true
|
138
|
-
escaped_with = @arguments[j]
|
139
|
-
|
140
|
-
j += 1 # step over first " or '
|
141
|
-
@white_spaces += 1
|
142
|
-
# identified "..." or '...'
|
143
|
-
# rubocop:disable Metrics/BlockNesting
|
144
|
-
while j < @arguments.size
|
145
|
-
case @arguments[j]
|
146
|
-
when '\\'
|
147
|
-
# eat the escape char but don't add it to the token, or we
|
148
|
-
# end up with \\\"
|
149
|
-
j += 1
|
150
|
-
@white_spaces += 1
|
151
|
-
break unless j < @arguments.size
|
152
|
-
when escaped_with
|
153
|
-
j += 1
|
154
|
-
@white_spaces += 1
|
155
|
-
break
|
156
|
-
end
|
157
|
-
current_token_value << @arguments[j]
|
158
|
-
j += 1
|
159
|
-
end
|
160
|
-
# rubocop:enable Metrics/BlockNesting
|
161
|
-
else
|
162
|
-
current_token_value << @arguments[j]
|
163
|
-
j += 1
|
164
|
-
end
|
165
|
-
|
166
|
-
break if @arguments[j] == " " && (is_klass?(j) && @arguments[j - 1] !~ /=|<|>/)
|
167
|
-
|
168
|
-
if (@arguments[j] == " ") && (@seperation_counter < 2) && !current_token_value.match(/^.+(=|<|>).+$/) && (index = lookahead(j))
|
169
|
-
j = index
|
170
|
-
end
|
171
|
-
break if (j >= @arguments.size) || (@arguments[j] =~ /\s|\)/)
|
172
|
-
end
|
173
|
-
@seperation_counter = 0
|
174
|
-
end
|
175
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
176
|
-
raise "An exception was raised while trying to tokenize '#{current_token_value} - #{e}'"
|
177
|
-
end
|
178
|
-
|
179
|
-
@token_index += current_token_value.size + @white_spaces - 1
|
180
|
-
@white_spaces = 0
|
181
|
-
|
182
|
-
# bar(
|
183
|
-
if current_token_value.match(/.+?\($/)
|
184
|
-
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
185
|
-
# /foo/=bar
|
186
|
-
elsif current_token_value.match(/^\/.+?\/(<|>|=).+/)
|
187
|
-
["bad_token", [@token_index - current_token_value.size + 1, @token_index]]
|
188
|
-
elsif current_token_value.match(/^.+?\/(<|>|=).+/)
|
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]
|
194
|
-
else
|
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 == "/"
|
203
|
-
end
|
204
|
-
return "bad_token", [@token_index - current_token_value.size + 1, @token_index] if slash_err
|
205
|
-
|
206
|
-
["statement", current_token_value]
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
# Deal with special puppet class statement
|
211
|
-
def is_klass?(klass)
|
212
|
-
klass += 1 while klass < @arguments.size && @arguments[klass] == " "
|
213
|
-
|
214
|
-
if @arguments[klass] =~ /=|<|>/
|
215
|
-
false
|
216
|
-
else
|
217
|
-
true
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
# Eat spaces while looking for the next comparison symbol
|
222
|
-
def lookahead(index)
|
223
|
-
index += 1
|
224
|
-
while index <= @arguments.size
|
225
|
-
@white_spaces += 1
|
226
|
-
unless @arguments[index] =~ /\s/
|
227
|
-
@seperation_counter += 1
|
228
|
-
return index
|
229
|
-
end
|
230
|
-
index += 1
|
231
|
-
end
|
232
|
-
nil
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|