choria-mcorpc-support 2.23.2 → 2.24.3
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.
- checksums.yaml +5 -5
- data/lib/mcollective.rb +3 -3
- data/lib/mcollective/agent/choria_util.ddl +206 -107
- data/lib/mcollective/agent/choria_util.json +101 -1
- data/lib/mcollective/agent/rpcutil.json +2 -3
- data/lib/mcollective/agent/scout.json +107 -135
- data/lib/mcollective/application/facts.rb +2 -67
- 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 +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/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 +16 -2
- metadata +9 -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
@@ -308,8 +308,7 @@
|
|
308
308
|
},
|
309
309
|
"machines": {
|
310
310
|
"description": "Autonomous Agents",
|
311
|
-
"display_as": "Machines"
|
312
|
-
"default": null
|
311
|
+
"display_as": "Machines"
|
313
312
|
}
|
314
313
|
},
|
315
314
|
"display": "always",
|
@@ -330,4 +329,4 @@
|
|
330
329
|
"description": "Responds to requests for PING with PONG"
|
331
330
|
}
|
332
331
|
]
|
333
|
-
}
|
332
|
+
}
|
@@ -1,122 +1,58 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
|
3
3
|
"metadata": {
|
4
|
-
"name": "scout",
|
5
|
-
"description": "Choria Scout Agent Management API",
|
6
|
-
"author": "R.I.Pienaar <rip@devco.net>",
|
7
4
|
"license": "Apache-2.0",
|
5
|
+
"author": "R.I.Pienaar <rip@devco.net>",
|
6
|
+
"timeout": 5,
|
7
|
+
"name": "scout",
|
8
8
|
"version": "0.0.1",
|
9
9
|
"url": "https://choria.io",
|
10
|
-
"
|
11
|
-
"
|
10
|
+
"description": "Choria Scout Agent Management API",
|
11
|
+
"provider": "golang"
|
12
12
|
},
|
13
13
|
"actions": [
|
14
14
|
{
|
15
15
|
"action": "checks",
|
16
|
-
"
|
17
|
-
|
16
|
+
"display": "ok",
|
17
|
+
"description": "Obtain a list of checks and their current status",
|
18
|
+
"input": {},
|
18
19
|
"output": {
|
19
20
|
"checks": {
|
20
21
|
"description": "Details about each check",
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"type": "array"
|
22
|
+
"type": "array",
|
23
|
+
"display_as": "Checks"
|
24
24
|
}
|
25
|
-
}
|
26
|
-
"display": "ok",
|
27
|
-
"description": "Obtain a list of checks and their current status"
|
25
|
+
}
|
28
26
|
},
|
29
27
|
{
|
30
|
-
"action": "
|
28
|
+
"action": "resume",
|
31
29
|
"input": {
|
32
|
-
"
|
33
|
-
"prompt": "
|
34
|
-
"description": "
|
35
|
-
"type": "
|
36
|
-
"
|
37
|
-
"optional": false,
|
38
|
-
"validation": ".+",
|
39
|
-
"maxlength": 256
|
40
|
-
},
|
41
|
-
"vars": {
|
42
|
-
"prompt": "Vars File",
|
43
|
-
"description": "Path to a file to use as template variables",
|
44
|
-
"type": "string",
|
45
|
-
"default": null,
|
46
|
-
"optional": true,
|
47
|
-
"validation": ".+",
|
48
|
-
"maxlength": 256
|
30
|
+
"checks": {
|
31
|
+
"prompt": "Checks",
|
32
|
+
"description": "Check to resume, empty means all",
|
33
|
+
"type": "array",
|
34
|
+
"optional": true
|
49
35
|
}
|
50
36
|
},
|
51
37
|
"output": {
|
52
|
-
"
|
53
|
-
"description": "
|
54
|
-
"display_as": "Failed
|
55
|
-
"default": null,
|
56
|
-
"type": "integer"
|
57
|
-
},
|
58
|
-
"results": {
|
59
|
-
"description": "The full test results",
|
60
|
-
"display_as": "Results",
|
61
|
-
"default": null,
|
38
|
+
"failed": {
|
39
|
+
"description": "List of checks that could not be resumed",
|
40
|
+
"display_as": "Failed",
|
62
41
|
"type": "array"
|
63
42
|
},
|
64
|
-
"
|
65
|
-
"description": "
|
66
|
-
"display_as": "
|
67
|
-
"
|
68
|
-
"type": "integer"
|
69
|
-
},
|
70
|
-
"success": {
|
71
|
-
"description": "Indicates if the test passed",
|
72
|
-
"display_as": "Success",
|
73
|
-
"default": null,
|
74
|
-
"type": "string"
|
75
|
-
},
|
76
|
-
"summary": {
|
77
|
-
"description": "A human friendly test result",
|
78
|
-
"display_as": "Summary",
|
79
|
-
"default": null,
|
80
|
-
"type": "string"
|
43
|
+
"transitioned": {
|
44
|
+
"description": "List of checks that were resumed",
|
45
|
+
"display_as": "Triggered",
|
46
|
+
"type": "array"
|
81
47
|
},
|
82
|
-
"
|
83
|
-
"description": "
|
84
|
-
"display_as": "
|
85
|
-
"
|
86
|
-
"type": "integer"
|
48
|
+
"skipped": {
|
49
|
+
"description": "List of checks that was skipped",
|
50
|
+
"display_as": "Skipped",
|
51
|
+
"type": "array"
|
87
52
|
}
|
88
53
|
},
|
89
54
|
"display": "failed",
|
90
|
-
"description": "
|
91
|
-
"aggregate": [
|
92
|
-
{
|
93
|
-
"function": "summary",
|
94
|
-
"args": [
|
95
|
-
"tests",
|
96
|
-
{
|
97
|
-
"format": "%s Test Cases on %d node(s)"
|
98
|
-
}
|
99
|
-
]
|
100
|
-
},
|
101
|
-
{
|
102
|
-
"function": "summary",
|
103
|
-
"args": [
|
104
|
-
"failures",
|
105
|
-
{
|
106
|
-
"format": "%s Failed Cases on %d node(s)"
|
107
|
-
}
|
108
|
-
]
|
109
|
-
},
|
110
|
-
{
|
111
|
-
"function": "summary",
|
112
|
-
"args": [
|
113
|
-
"success",
|
114
|
-
{
|
115
|
-
"format": "%s Passed Cases on %d node(s)"
|
116
|
-
}
|
117
|
-
]
|
118
|
-
}
|
119
|
-
]
|
55
|
+
"description": "Resume active checking of one or more checks"
|
120
56
|
},
|
121
57
|
{
|
122
58
|
"action": "maintenance",
|
@@ -125,7 +61,6 @@
|
|
125
61
|
"prompt": "Checks",
|
126
62
|
"description": "Check to pause, empty means all",
|
127
63
|
"type": "array",
|
128
|
-
"default": null,
|
129
64
|
"optional": true
|
130
65
|
}
|
131
66
|
},
|
@@ -133,19 +68,16 @@
|
|
133
68
|
"failed": {
|
134
69
|
"description": "List of checks that could not be paused",
|
135
70
|
"display_as": "Failed",
|
136
|
-
"default": null,
|
137
|
-
"type": "array"
|
138
|
-
},
|
139
|
-
"skipped": {
|
140
|
-
"description": "List of checks that was skipped",
|
141
|
-
"display_as": "Skipped",
|
142
|
-
"default": null,
|
143
71
|
"type": "array"
|
144
72
|
},
|
145
73
|
"transitioned": {
|
146
74
|
"description": "List of checks that were paused",
|
147
75
|
"display_as": "Triggered",
|
148
|
-
"
|
76
|
+
"type": "array"
|
77
|
+
},
|
78
|
+
"skipped": {
|
79
|
+
"description": "List of checks that was skipped",
|
80
|
+
"display_as": "Skipped",
|
149
81
|
"type": "array"
|
150
82
|
}
|
151
83
|
},
|
@@ -153,38 +85,82 @@
|
|
153
85
|
"description": "Pause checking of one or more checks"
|
154
86
|
},
|
155
87
|
{
|
156
|
-
"action": "
|
88
|
+
"action": "goss_validate",
|
89
|
+
"description": "Performs a Goss validation using a specific file",
|
90
|
+
"display": "failed",
|
91
|
+
"aggregate": [
|
92
|
+
{
|
93
|
+
"function": "summary",
|
94
|
+
"args": [
|
95
|
+
"tests",
|
96
|
+
{"format": "%s Tests on %d node(s)"}
|
97
|
+
]
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"function": "summary",
|
101
|
+
"args": [
|
102
|
+
"failures",
|
103
|
+
{"format": "%s Failed test on %d node(s)"}
|
104
|
+
]
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"function": "summary",
|
108
|
+
"args": [
|
109
|
+
"success",
|
110
|
+
{"format": "%s Passed tests on %d node(s)"}
|
111
|
+
]
|
112
|
+
}
|
113
|
+
],
|
157
114
|
"input": {
|
158
|
-
"
|
159
|
-
"prompt": "
|
160
|
-
"description": "
|
161
|
-
"type": "
|
162
|
-
"
|
115
|
+
"file": {
|
116
|
+
"prompt": "Goss File",
|
117
|
+
"description": "Path to the Goss validation specification",
|
118
|
+
"type": "string",
|
119
|
+
"maxlength": 256,
|
120
|
+
"validation": ".+",
|
121
|
+
"optional": false
|
122
|
+
},
|
123
|
+
"vars": {
|
124
|
+
"prompt": "Vars File",
|
125
|
+
"description": "Path to a file to use as template variables",
|
126
|
+
"type": "string",
|
127
|
+
"maxlength": 256,
|
128
|
+
"validation": ".+",
|
163
129
|
"optional": true
|
164
130
|
}
|
165
131
|
},
|
166
132
|
"output": {
|
167
|
-
"
|
168
|
-
"description": "
|
169
|
-
"display_as": "
|
170
|
-
"
|
171
|
-
"type": "array"
|
133
|
+
"tests": {
|
134
|
+
"description": "The number of tests that were run",
|
135
|
+
"display_as": "Tests",
|
136
|
+
"type": "integer"
|
172
137
|
},
|
173
|
-
"
|
174
|
-
"description": "
|
175
|
-
"display_as": "
|
176
|
-
"
|
177
|
-
"type": "array"
|
138
|
+
"failures": {
|
139
|
+
"description": "The number of tests that failed",
|
140
|
+
"display_as": "Failed Tests",
|
141
|
+
"type": "integer"
|
178
142
|
},
|
179
|
-
"
|
180
|
-
"description": "
|
181
|
-
"display_as": "
|
182
|
-
"
|
143
|
+
"runtime": {
|
144
|
+
"description": "The time it took to run the tests, in seconds",
|
145
|
+
"display_as": "Runtime",
|
146
|
+
"type": "integer"
|
147
|
+
},
|
148
|
+
"success": {
|
149
|
+
"description": "Indicates if the test passed",
|
150
|
+
"display_as": "Success",
|
151
|
+
"type": "string"
|
152
|
+
},
|
153
|
+
"summary": {
|
154
|
+
"description": "A human friendly test result",
|
155
|
+
"display_as": "Summary",
|
156
|
+
"type": "string"
|
157
|
+
},
|
158
|
+
"results": {
|
159
|
+
"description": "The full test results",
|
160
|
+
"display_as": "Results",
|
183
161
|
"type": "array"
|
184
162
|
}
|
185
|
-
}
|
186
|
-
"display": "failed",
|
187
|
-
"description": "Resume active checking of one or more checks"
|
163
|
+
}
|
188
164
|
},
|
189
165
|
{
|
190
166
|
"action": "trigger",
|
@@ -193,7 +169,6 @@
|
|
193
169
|
"prompt": "Checks",
|
194
170
|
"description": "Check to trigger, empty means all",
|
195
171
|
"type": "array",
|
196
|
-
"default": null,
|
197
172
|
"optional": true
|
198
173
|
}
|
199
174
|
},
|
@@ -201,19 +176,16 @@
|
|
201
176
|
"failed": {
|
202
177
|
"description": "List of checks that could not be triggered",
|
203
178
|
"display_as": "Failed",
|
204
|
-
"default": null,
|
205
|
-
"type": "array"
|
206
|
-
},
|
207
|
-
"skipped": {
|
208
|
-
"description": "List of checks that was skipped",
|
209
|
-
"display_as": "Skipped",
|
210
|
-
"default": null,
|
211
179
|
"type": "array"
|
212
180
|
},
|
213
181
|
"transitioned": {
|
214
182
|
"description": "List of checks that were triggered",
|
215
183
|
"display_as": "Triggered",
|
216
|
-
"
|
184
|
+
"type": "array"
|
185
|
+
},
|
186
|
+
"skipped": {
|
187
|
+
"description": "List of checks that was skipped",
|
188
|
+
"display_as": "Skipped",
|
217
189
|
"type": "array"
|
218
190
|
}
|
219
191
|
},
|
@@ -221,4 +193,4 @@
|
|
221
193
|
"description": "Force an immediate check of one or more checks"
|
222
194
|
}
|
223
195
|
]
|
224
|
-
}
|
196
|
+
}
|
@@ -1,71 +1,6 @@
|
|
1
1
|
class MCollective::Application::Facts < MCollective::Application # rubocop:disable Style/ClassAndModuleChildren
|
2
2
|
description "Reports on usage for a specific fact"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
def validate_configuration(configuration)
|
9
|
-
raise "Please specify a fact to report for" unless configuration.include?(:fact)
|
10
|
-
end
|
11
|
-
|
12
|
-
def show_single_fact_report(fact, facts, verbose=false)
|
13
|
-
puts("Report for fact: #{fact}\n\n")
|
14
|
-
|
15
|
-
facts = stringify_facts_hash(facts)
|
16
|
-
|
17
|
-
field_size = MCollective::Util.field_size(facts.keys)
|
18
|
-
facts.keys.sort.each do |k|
|
19
|
-
printf(" %-#{field_size}s found %d times\n", k, facts[k].size)
|
20
|
-
|
21
|
-
next unless verbose
|
22
|
-
|
23
|
-
puts
|
24
|
-
|
25
|
-
facts[k].sort.each do |f|
|
26
|
-
puts(" #{f}")
|
27
|
-
end
|
28
|
-
|
29
|
-
puts
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def stringify_facts_hash(facts)
|
34
|
-
res = Hash.new([])
|
35
|
-
facts.each { |k, v| res[k.to_s] += v }
|
36
|
-
res
|
37
|
-
end
|
38
|
-
|
39
|
-
def main
|
40
|
-
rpcutil = rpcclient("rpcutil")
|
41
|
-
rpcutil.progress = false
|
42
|
-
|
43
|
-
facts = {}
|
44
|
-
|
45
|
-
rpcutil.get_fact(:fact => configuration[:fact]) do |resp|
|
46
|
-
begin
|
47
|
-
value = resp[:body][:data][:value].to_s
|
48
|
-
|
49
|
-
if resp[:body][:data].include?(:value)
|
50
|
-
if facts.include?(value)
|
51
|
-
facts[value] << resp[:senderid]
|
52
|
-
else
|
53
|
-
facts[value] = [resp[:senderid]]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
57
|
-
warn "Could not parse facts for #{resp[:senderid]}: #{e.class}: #{e}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
if facts.empty?
|
62
|
-
puts "No values found for fact #{configuration[:fact]}\n"
|
63
|
-
else
|
64
|
-
show_single_fact_report(configuration[:fact], facts, options[:verbose])
|
65
|
-
end
|
66
|
-
|
67
|
-
printrpcstats
|
68
|
-
|
69
|
-
halt rpcutil.stats
|
70
|
-
end
|
4
|
+
external(:command => "choria", :args => ["facts"])
|
5
|
+
external_help(:command => "choria", :args => ["facts", "--help"])
|
71
6
|
end
|
@@ -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
|
|