choria-mcorpc-support 2.21.1 → 2.23.1

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mcollective.rb +1 -2
  3. data/lib/mcollective/agent/bolt_tasks.ddl +253 -0
  4. data/lib/mcollective/agent/bolt_tasks.json +365 -0
  5. data/lib/mcollective/agent/bolt_tasks.rb +178 -0
  6. data/lib/mcollective/agent/choria_util.ddl +152 -0
  7. data/lib/mcollective/agent/choria_util.json +244 -0
  8. data/lib/mcollective/agent/rpcutil.ddl +8 -4
  9. data/lib/mcollective/agent/rpcutil.json +333 -0
  10. data/lib/mcollective/agent/scout.ddl +169 -0
  11. data/lib/mcollective/agent/scout.json +224 -0
  12. data/lib/mcollective/agents.rb +7 -6
  13. data/lib/mcollective/aggregate.rb +4 -4
  14. data/lib/mcollective/aggregate/average.rb +2 -2
  15. data/lib/mcollective/aggregate/base.rb +2 -2
  16. data/lib/mcollective/aggregate/result.rb +3 -3
  17. data/lib/mcollective/aggregate/result/collection_result.rb +2 -2
  18. data/lib/mcollective/aggregate/result/numeric_result.rb +2 -2
  19. data/lib/mcollective/aggregate/sum.rb +2 -2
  20. data/lib/mcollective/aggregate/summary.rb +3 -4
  21. data/lib/mcollective/application.rb +57 -21
  22. data/lib/mcollective/application/choria.rb +189 -0
  23. data/lib/mcollective/application/completion.rb +6 -6
  24. data/lib/mcollective/application/facts.rb +11 -11
  25. data/lib/mcollective/application/federation.rb +237 -0
  26. data/lib/mcollective/application/find.rb +4 -4
  27. data/lib/mcollective/application/help.rb +3 -3
  28. data/lib/mcollective/application/inventory.rb +3 -341
  29. data/lib/mcollective/application/ping.rb +5 -51
  30. data/lib/mcollective/application/playbook.rb +207 -0
  31. data/lib/mcollective/application/plugin.rb +106 -106
  32. data/lib/mcollective/application/rpc.rb +3 -108
  33. data/lib/mcollective/application/tasks.rb +425 -0
  34. data/lib/mcollective/applications.rb +11 -10
  35. data/lib/mcollective/audit/choria.rb +33 -0
  36. data/lib/mcollective/cache.rb +2 -4
  37. data/lib/mcollective/client.rb +11 -10
  38. data/lib/mcollective/config.rb +21 -34
  39. data/lib/mcollective/connector/base.rb +2 -1
  40. data/lib/mcollective/connector/nats.ddl +9 -0
  41. data/lib/mcollective/connector/nats.rb +450 -0
  42. data/lib/mcollective/data.rb +8 -3
  43. data/lib/mcollective/data/agent_data.rb +1 -1
  44. data/lib/mcollective/data/base.rb +6 -5
  45. data/lib/mcollective/data/bolt_task_data.ddl +90 -0
  46. data/lib/mcollective/data/bolt_task_data.rb +32 -0
  47. data/lib/mcollective/data/collective_data.rb +1 -1
  48. data/lib/mcollective/data/fact_data.rb +6 -6
  49. data/lib/mcollective/data/fstat_data.rb +2 -4
  50. data/lib/mcollective/data/result.rb +7 -2
  51. data/lib/mcollective/ddl/agentddl.rb +5 -17
  52. data/lib/mcollective/ddl/base.rb +10 -13
  53. data/lib/mcollective/discovery.rb +24 -39
  54. data/lib/mcollective/discovery/choria.ddl +11 -0
  55. data/lib/mcollective/discovery/choria.rb +223 -0
  56. data/lib/mcollective/discovery/flatfile.rb +7 -8
  57. data/lib/mcollective/discovery/mc.rb +2 -2
  58. data/lib/mcollective/discovery/stdin.rb +17 -18
  59. data/lib/mcollective/exceptions.rb +13 -0
  60. data/lib/mcollective/facts/base.rb +9 -9
  61. data/lib/mcollective/facts/yaml_facts.rb +12 -12
  62. data/lib/mcollective/generators.rb +3 -3
  63. data/lib/mcollective/generators/agent_generator.rb +3 -4
  64. data/lib/mcollective/generators/base.rb +14 -15
  65. data/lib/mcollective/generators/data_generator.rb +5 -6
  66. data/lib/mcollective/log.rb +2 -2
  67. data/lib/mcollective/logger/base.rb +3 -2
  68. data/lib/mcollective/logger/console_logger.rb +10 -10
  69. data/lib/mcollective/logger/file_logger.rb +7 -7
  70. data/lib/mcollective/logger/syslog_logger.rb +11 -15
  71. data/lib/mcollective/message.rb +8 -39
  72. data/lib/mcollective/monkey_patches.rb +2 -4
  73. data/lib/mcollective/optionparser.rb +2 -1
  74. data/lib/mcollective/pluginmanager.rb +3 -5
  75. data/lib/mcollective/pluginpackager.rb +1 -3
  76. data/lib/mcollective/pluginpackager/agent_definition.rb +3 -8
  77. data/lib/mcollective/pluginpackager/forge_packager.rb +7 -9
  78. data/lib/mcollective/pluginpackager/standard_definition.rb +1 -2
  79. data/lib/mcollective/registration/base.rb +18 -16
  80. data/lib/mcollective/rpc.rb +2 -4
  81. data/lib/mcollective/rpc/actionrunner.rb +16 -18
  82. data/lib/mcollective/rpc/agent.rb +26 -43
  83. data/lib/mcollective/rpc/audit.rb +1 -0
  84. data/lib/mcollective/rpc/client.rb +67 -85
  85. data/lib/mcollective/rpc/helpers.rb +55 -62
  86. data/lib/mcollective/rpc/progress.rb +2 -2
  87. data/lib/mcollective/rpc/reply.rb +17 -19
  88. data/lib/mcollective/rpc/request.rb +7 -5
  89. data/lib/mcollective/rpc/result.rb +6 -8
  90. data/lib/mcollective/rpc/stats.rb +49 -58
  91. data/lib/mcollective/security/base.rb +13 -56
  92. data/lib/mcollective/security/choria.rb +765 -0
  93. data/lib/mcollective/shell.rb +9 -4
  94. data/lib/mcollective/signer/base.rb +28 -0
  95. data/lib/mcollective/signer/choria.rb +185 -0
  96. data/lib/mcollective/ssl.rb +8 -6
  97. data/lib/mcollective/util.rb +58 -55
  98. data/lib/mcollective/util/bolt_support.rb +176 -0
  99. data/lib/mcollective/util/bolt_support/plan_runner.rb +167 -0
  100. data/lib/mcollective/util/bolt_support/task_result.rb +94 -0
  101. data/lib/mcollective/util/bolt_support/task_results.rb +128 -0
  102. data/lib/mcollective/util/choria.rb +946 -0
  103. data/lib/mcollective/util/indifferent_hash.rb +12 -0
  104. data/lib/mcollective/util/natswrapper.rb +242 -0
  105. data/lib/mcollective/util/playbook.rb +435 -0
  106. data/lib/mcollective/util/playbook/data_stores.rb +201 -0
  107. data/lib/mcollective/util/playbook/data_stores/base.rb +99 -0
  108. data/lib/mcollective/util/playbook/data_stores/consul_data_store.rb +88 -0
  109. data/lib/mcollective/util/playbook/data_stores/environment_data_store.rb +33 -0
  110. data/lib/mcollective/util/playbook/data_stores/etcd_data_store.rb +42 -0
  111. data/lib/mcollective/util/playbook/data_stores/file_data_store.rb +106 -0
  112. data/lib/mcollective/util/playbook/data_stores/shell_data_store.rb +103 -0
  113. data/lib/mcollective/util/playbook/inputs.rb +265 -0
  114. data/lib/mcollective/util/playbook/nodes.rb +207 -0
  115. data/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb +86 -0
  116. data/lib/mcollective/util/playbook/nodes/pql_nodes.rb +40 -0
  117. data/lib/mcollective/util/playbook/nodes/shell_nodes.rb +55 -0
  118. data/lib/mcollective/util/playbook/nodes/terraform_nodes.rb +65 -0
  119. data/lib/mcollective/util/playbook/nodes/yaml_nodes.rb +47 -0
  120. data/lib/mcollective/util/playbook/playbook_logger.rb +47 -0
  121. data/lib/mcollective/util/playbook/puppet_logger.rb +51 -0
  122. data/lib/mcollective/util/playbook/report.rb +152 -0
  123. data/lib/mcollective/util/playbook/task_result.rb +55 -0
  124. data/lib/mcollective/util/playbook/tasks.rb +196 -0
  125. data/lib/mcollective/util/playbook/tasks/base.rb +45 -0
  126. data/lib/mcollective/util/playbook/tasks/graphite_event_task.rb +64 -0
  127. data/lib/mcollective/util/playbook/tasks/mcollective_task.rb +356 -0
  128. data/lib/mcollective/util/playbook/tasks/shell_task.rb +93 -0
  129. data/lib/mcollective/util/playbook/tasks/slack_task.rb +105 -0
  130. data/lib/mcollective/util/playbook/tasks/webhook_task.rb +136 -0
  131. data/lib/mcollective/util/playbook/template_util.rb +98 -0
  132. data/lib/mcollective/util/playbook/uses.rb +169 -0
  133. data/lib/mcollective/util/tasks_support.rb +751 -0
  134. data/lib/mcollective/util/tasks_support/cli.rb +260 -0
  135. data/lib/mcollective/util/tasks_support/default_formatter.rb +138 -0
  136. data/lib/mcollective/util/tasks_support/json_formatter.rb +108 -0
  137. data/lib/mcollective/validator.rb +6 -1
  138. data/lib/mcollective/validator/bolt_task_name_validator.ddl +7 -0
  139. data/lib/mcollective/validator/bolt_task_name_validator.rb +11 -0
  140. data/lib/mcollective/validator/length_validator.rb +1 -3
  141. metadata +65 -6
  142. data/lib/mcollective/application/describe_filter.rb +0 -87
  143. data/lib/mcollective/matcher.rb +0 -220
  144. data/lib/mcollective/matcher/parser.rb +0 -128
  145. data/lib/mcollective/matcher/scanner.rb +0 -241
@@ -1,128 +0,0 @@
1
- module MCollective
2
- module Matcher
3
- class Parser
4
- attr_reader :scanner, :execution_stack
5
-
6
- def initialize(args)
7
- @scanner = Scanner.new(args)
8
- @execution_stack = []
9
- @parse_errors = []
10
- @token_errors = []
11
- @paren_errors = []
12
- parse
13
- exit_with_token_errors if @token_errors.size > 0
14
- exit_with_parse_errors if @parse_errors.size > 0
15
- exit_with_paren_errors if @paren_errors.size > 0
16
- end
17
-
18
- # Exit and highlight any malformed tokens
19
- def exit_with_token_errors
20
- @token_errors.each do |error_range|
21
- (error_range[0]..error_range[1]).each do |i|
22
- @scanner.arguments[i] = Util.colorize(:red, @scanner.arguments[i])
23
- end
24
- end
25
- raise "Malformed token(s) found while parsing -S input #{@scanner.arguments.join}"
26
- end
27
-
28
- def exit_with_parse_errors
29
- @parse_errors.each do |error_range|
30
- (error_range[0]..error_range[1]).each do |i|
31
- @scanner.arguments[i] = Util.colorize(:red, @scanner.arguments[i])
32
- end
33
- end
34
- raise "Parse errors found while parsing -S input #{ @scanner.arguments.join}"
35
- end
36
-
37
- def exit_with_paren_errors
38
- @paren_errors.each do |i|
39
- @scanner.arguments[i] = Util.colorize(:red, @scanner.arguments[i])
40
- end
41
- raise "Missing parenthesis found while parsing -S input #{@scanner.arguments.join}"
42
- end
43
-
44
- # Parse the input string, one token at a time a contruct the call stack
45
- def parse
46
- pre_index = @scanner.token_index
47
- p_token,p_token_value = nil
48
- c_token,c_token_value = @scanner.get_token
49
- parenth = 0
50
-
51
- while (c_token != nil)
52
- @scanner.token_index += 1
53
- n_token, n_token_value = @scanner.get_token
54
-
55
- unless n_token == " "
56
- case c_token
57
- when "bad_token"
58
- @token_errors << c_token_value
59
-
60
- when "and"
61
- unless (n_token =~ /not|fstatement|statement|\(/) || (scanner.token_index == scanner.arguments.size) && !(n_token == nil)
62
- @parse_errors << [pre_index, scanner.token_index]
63
- end
64
-
65
- if p_token == nil
66
- @parse_errors << [pre_index - c_token.size, scanner.token_index]
67
- elsif (p_token == "and" || p_token == "or")
68
- @parse_errors << [pre_index - 1 - p_token.size, pre_index - 1]
69
- end
70
-
71
- when "or"
72
- unless (n_token =~ /not|fstatement|statement|\(/) || (scanner.token_index == scanner.arguments.size) && !(n_token == nil)
73
- @parse_errors << [pre_index, scanner.token_index]
74
- end
75
-
76
- if p_token == nil
77
- @parse_errors << [pre_index - c_token.size, scanner.token_index]
78
- elsif (p_token == "and" || p_token == "or")
79
- @parse_errors << [pre_index - 1 - p_token.size, pre_index - 1]
80
- end
81
-
82
- when "not"
83
- unless n_token =~ /fstatement|statement|\(|not/ && !(n_token == nil)
84
- @parse_errors << [pre_index, scanner.token_index]
85
- end
86
-
87
- when "statement","fstatement"
88
- unless n_token =~ /and|or|\)/
89
- unless scanner.token_index == scanner.arguments.size
90
- @parse_errors << [pre_index, scanner.token_index]
91
- end
92
- end
93
-
94
- when ")"
95
- unless (n_token =~ /|and|or|not|\(/)
96
- unless(scanner.token_index == scanner.arguments.size)
97
- @parse_errors << [pre_index, scanner.token_index]
98
- end
99
- end
100
- unless @paren_errors.empty?
101
- @paren_errors.pop
102
- else
103
- @paren_errors.push((n_token.nil?) ? scanner.token_index - 1: scanner.token_index - n_token_value.size)
104
- end
105
-
106
- when "("
107
- unless n_token =~ /fstatement|statement|not|\(/
108
- @parse_errors << [pre_index, scanner.token_index]
109
- end
110
- @paren_errors.push((n_token.nil?) ? scanner.token_index - 1: scanner.token_index - n_token_value.size)
111
-
112
- else
113
- @parse_errors << [pre_index, scanner.token_index]
114
- end
115
-
116
- unless n_token == " " ||c_token == "bad_token"
117
- @execution_stack << {c_token => c_token_value}
118
- end
119
-
120
- p_token, p_token_value = c_token, c_token_value
121
- c_token, c_token_value = n_token, n_token_value
122
- end
123
- pre_index = @scanner.token_index
124
- end
125
- end
126
- end
127
- end
128
- end
@@ -1,241 +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
15
- if @token_index >= @arguments.size
16
- return nil
17
- end
18
-
19
- case @arguments[@token_index]
20
- when "("
21
- return "(", "("
22
-
23
- when ")"
24
- return ")", ")"
25
-
26
- when "n"
27
- if (@arguments[@token_index + 1] == "o") && (@arguments[@token_index + 2] == "t") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
28
- @token_index += 2
29
- return "not", "not"
30
- else
31
- gen_statement
32
- end
33
-
34
- when "!"
35
- return "not", "not"
36
-
37
- when "a"
38
- if (@arguments[@token_index + 1] == "n") && (@arguments[@token_index + 2] == "d") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
39
- @token_index += 2
40
- return "and", "and"
41
- else
42
- gen_statement
43
- end
44
-
45
- when "o"
46
- if (@arguments[@token_index + 1] == "r") && ((@arguments[@token_index + 2] == " ") || (@arguments[@token_index + 2] == "("))
47
- @token_index += 1
48
- return "or", "or"
49
- else
50
- gen_statement
51
- end
52
-
53
- when " "
54
- return " ", " "
55
-
56
- else
57
- gen_statement
58
- end
59
- end
60
-
61
- private
62
- # Helper generates a statement token
63
- def gen_statement
64
- func = false
65
- current_token_value = ""
66
- j = @token_index
67
- escaped = false
68
-
69
- begin
70
- if (@arguments[j] == "/")
71
- begin
72
- current_token_value << @arguments[j]
73
- j += 1
74
- end until (j >= @arguments.size) || (@arguments[j] =~ /\s/)
75
- elsif (@arguments[j] =~ /=|<|>/)
76
- while !(@arguments[j] =~ /=|<|>/)
77
- current_token_value << @arguments[j]
78
- j += 1
79
- end
80
-
81
- current_token_value << @arguments[j]
82
- j += 1
83
-
84
- if @arguments[j] == "/"
85
- begin
86
- current_token_value << @arguments[j]
87
- j += 1
88
- if @arguments[j] == "/"
89
- current_token_value << "/"
90
- break
91
- end
92
- end until (j >= @arguments.size) || (@arguments[j] =~ /\//)
93
- while (j < @arguments.size) && ((@arguments[j] != " ") && (@arguments[j] != ")"))
94
- current_token_value << @arguments[j]
95
- j += 1
96
- end
97
- end
98
- else
99
- begin
100
- # Identify and tokenize regular expressions by ignoring everything between /'s
101
- if @arguments[j] == '/'
102
- current_token_value << '/'
103
- j += 1
104
- while(j < @arguments.size && @arguments[j] != '/')
105
- if @arguments[j] == '\\'
106
- # eat the escape char
107
- current_token_value << @arguments[j]
108
- j += 1
109
- escaped = true
110
- end
111
-
112
- current_token_value << @arguments[j]
113
- j += 1
114
- end
115
- current_token_value << @arguments[j] if @arguments[j]
116
- break
117
- end
118
-
119
- if @arguments[j] == "("
120
- func = true
121
-
122
- current_token_value << @arguments[j]
123
- j += 1
124
-
125
- while j < @arguments.size
126
- current_token_value << @arguments[j]
127
- if @arguments[j] == ')'
128
- j += 1
129
- break
130
- end
131
- j += 1
132
- end
133
- elsif @arguments[j] == '"' || @arguments[j] == "'"
134
- escaped = true
135
- escaped_with = @arguments[j]
136
-
137
- j += 1 # step over first " or '
138
- @white_spaces += 1
139
- # identified "..." or '...'
140
- while j < @arguments.size
141
- if @arguments[j] == '\\'
142
- # eat the escape char but don't add it to the token, or we
143
- # end up with \\\"
144
- j += 1
145
- @white_spaces += 1
146
- unless j < @arguments.size
147
- break
148
- end
149
- elsif @arguments[j] == escaped_with
150
- j += 1
151
- @white_spaces += 1
152
- break
153
- end
154
- current_token_value << @arguments[j]
155
- j += 1
156
- end
157
- else
158
- current_token_value << @arguments[j]
159
- j += 1
160
- end
161
-
162
- if(@arguments[j] == ' ')
163
- break if(is_klass?(j) && !(@arguments[j-1] =~ /=|<|>/))
164
- end
165
-
166
- if( (@arguments[j] == ' ') && (@seperation_counter < 2) && !(current_token_value.match(/^.+(=|<|>).+$/)) )
167
- if((index = lookahead(j)))
168
- j = index
169
- end
170
- end
171
- end until (j >= @arguments.size) || (@arguments[j] =~ /\s|\)/)
172
- @seperation_counter = 0
173
- end
174
- rescue Exception => e
175
- raise "An exception was raised while trying to tokenize '#{current_token_value} - #{e}'"
176
- end
177
-
178
- @token_index += current_token_value.size + @white_spaces - 1
179
- @white_spaces = 0
180
-
181
- # bar(
182
- if current_token_value.match(/.+?\($/)
183
- return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
184
- # /foo/=bar
185
- elsif current_token_value.match(/^\/.+?\/(<|>|=).+/)
186
- return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
187
- elsif current_token_value.match(/^.+?\/(<|>|=).+/)
188
- return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
189
- else
190
- if 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
- return "fstatement", current_token_value
194
- else
195
- return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
196
- end
197
- else
198
- if escaped
199
- return "statement", current_token_value
200
- end
201
- slash_err = false
202
- current_token_value.split('').each do |c|
203
- if c == '/'
204
- slash_err = !slash_err
205
- end
206
- end
207
- return "bad_token", [@token_index - current_token_value.size + 1, @token_index] if slash_err
208
- return "statement", current_token_value
209
- end
210
- end
211
- end
212
-
213
- # Deal with special puppet class statement
214
- def is_klass?(j)
215
- while(j < @arguments.size && @arguments[j] == ' ')
216
- j += 1
217
- end
218
-
219
- if @arguments[j] =~ /=|<|>/
220
- return false
221
- else
222
- return true
223
- end
224
- end
225
-
226
- # Eat spaces while looking for the next comparison symbol
227
- def lookahead(index)
228
- index += 1
229
- while(index <= @arguments.size)
230
- @white_spaces += 1
231
- unless(@arguments[index] =~ /\s/)
232
- @seperation_counter +=1
233
- return index
234
- end
235
- index += 1
236
- end
237
- return nil
238
- end
239
- end
240
- end
241
- end