choria-mcorpc-support 2.23.1 → 2.24.2
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 -2
- 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 +2 -15
- data/lib/mcollective/client.rb +1 -1
- data/lib/mcollective/config.rb +135 -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/generators.rb +0 -1
- 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 +25 -35
- data/lib/mcollective/util/tasks_support.rb +15 -2
- metadata +9 -23
- 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
@@ -1,67 +0,0 @@
|
|
1
|
-
# discovers against stdin instead of the traditional network discovery
|
2
|
-
# the input must be a flat file with a node name per line which should match identities as configured,
|
3
|
-
# or it should be a json string as output by the -j option of mco rpc
|
4
|
-
require "mcollective/rpc/helpers"
|
5
|
-
|
6
|
-
module MCollective
|
7
|
-
class Discovery
|
8
|
-
class Stdin
|
9
|
-
def self.discover(filter, timeout, limit=0, client=nil)
|
10
|
-
if client.options[:discovery_options].empty?
|
11
|
-
type = "auto"
|
12
|
-
else
|
13
|
-
type = client.options[:discovery_options].first.downcase
|
14
|
-
end
|
15
|
-
|
16
|
-
discovered = []
|
17
|
-
|
18
|
-
file = $stdin.read
|
19
|
-
|
20
|
-
raise("data piped on STDIN contained only whitespace - could not discover hosts from it.") if file =~ /^\s*$/
|
21
|
-
|
22
|
-
if type == "auto"
|
23
|
-
if file =~ /^\s*\[/
|
24
|
-
type = "json"
|
25
|
-
else
|
26
|
-
type = "text"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Log.debug("Parsing STDIN input as type %s" % type)
|
31
|
-
|
32
|
-
case type
|
33
|
-
when "json"
|
34
|
-
hosts = RPC::Helpers.extract_hosts_from_json(file)
|
35
|
-
when "text"
|
36
|
-
hosts = file.split("\n")
|
37
|
-
else
|
38
|
-
raise("stdin discovery plugin only knows the types auto/text/json, not \"#{type}\"")
|
39
|
-
end
|
40
|
-
|
41
|
-
hosts.map do |host|
|
42
|
-
raise 'Identities can only match /\w\.\-/' unless host.match(/^[\w.\-]+$/)
|
43
|
-
|
44
|
-
host
|
45
|
-
end
|
46
|
-
|
47
|
-
# this plugin only supports identity filters, do regex matches etc against
|
48
|
-
# the list found in the flatfile
|
49
|
-
if filter["identity"].empty?
|
50
|
-
discovered = hosts
|
51
|
-
else
|
52
|
-
filter["identity"].each do |identity|
|
53
|
-
identity = Regexp.new(identity.gsub("\/", "")) if identity.match("^/")
|
54
|
-
|
55
|
-
if identity.is_a?(Regexp)
|
56
|
-
discovered = hosts.grep(identity)
|
57
|
-
elsif hosts.include?(identity)
|
58
|
-
discovered << identity
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
discovered
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module MCollective
|
2
|
-
module Generators
|
3
|
-
class DataGenerator < Base
|
4
|
-
attr_accessor :ddl, :content
|
5
|
-
|
6
|
-
def initialize(plugin_name, outputs=[], name=nil, description=nil, author=nil,
|
7
|
-
license=nil, version=nil, url=nil, timeout=nil)
|
8
|
-
|
9
|
-
super(name, description, author, license, version, url, timeout)
|
10
|
-
@mod_name = "Data"
|
11
|
-
@pclass = "Base"
|
12
|
-
@plugin_name = plugin_name
|
13
|
-
@outputs = outputs
|
14
|
-
@ddl = create_ddl
|
15
|
-
@content = create_plugin_content
|
16
|
-
@plugin = create_plugin_string
|
17
|
-
write_plugins
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_ddl
|
21
|
-
query_text = "dataquery :description => \"Query information\" do\n"
|
22
|
-
query_text += ERB.new(File.read(File.join(File.dirname(__FILE__), "templates", "data_input_snippet.erb"))).result
|
23
|
-
|
24
|
-
@outputs.each_with_index do |output, i|
|
25
|
-
query_text += "%2s%s" % [" ", "output :#{output},\n"]
|
26
|
-
query_text += "%9s%s" % [" ", ":description => \"%DESCRIPTION%\",\n"]
|
27
|
-
query_text += "%9s%s" % [" ", ":display_as => \"%DESCRIPTION%\"\n"]
|
28
|
-
query_text += "\n" unless @outputs.size == (i + 1)
|
29
|
-
end
|
30
|
-
|
31
|
-
query_text += "end"
|
32
|
-
|
33
|
-
# Use inherited method to create metadata part of the ddl
|
34
|
-
create_metadata_string + query_text
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_plugin_content
|
38
|
-
content_text = "%6s%s" % [" ", "query do |what|\n"]
|
39
|
-
|
40
|
-
@outputs.each do |output|
|
41
|
-
content_text += "%8s%s" % [" ", "result[:#{output}] = nil\n"]
|
42
|
-
end
|
43
|
-
content_text += "%6s%s" % [" ", "end\n"]
|
44
|
-
|
45
|
-
# Add actions to agent file
|
46
|
-
content_text
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|