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.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/lib/mcollective.rb +3 -3
  3. data/lib/mcollective/agent/choria_util.ddl +206 -107
  4. data/lib/mcollective/agent/choria_util.json +101 -1
  5. data/lib/mcollective/agent/rpcutil.json +2 -3
  6. data/lib/mcollective/agent/scout.json +107 -135
  7. data/lib/mcollective/application/facts.rb +2 -67
  8. data/lib/mcollective/application/find.rb +1 -1
  9. data/lib/mcollective/application/plugin.rb +8 -173
  10. data/lib/mcollective/client.rb +1 -1
  11. data/lib/mcollective/config.rb +145 -103
  12. data/lib/mcollective/ddl.rb +0 -1
  13. data/lib/mcollective/discovery.rb +11 -63
  14. data/lib/mcollective/discovery/broadcast.ddl +11 -0
  15. data/lib/mcollective/discovery/choria.ddl +6 -4
  16. data/lib/mcollective/discovery/delegate.ddl +13 -0
  17. data/lib/mcollective/discovery/delegate.rb +73 -0
  18. data/lib/mcollective/discovery/external.ddl +13 -0
  19. data/lib/mcollective/discovery/file.ddl +13 -0
  20. data/lib/mcollective/discovery/flatfile.ddl +7 -5
  21. data/lib/mcollective/discovery/inventory.ddl +13 -0
  22. data/lib/mcollective/discovery/mc.ddl +3 -3
  23. data/lib/mcollective/log.rb +1 -2
  24. data/lib/mcollective/optionparser.rb +1 -1
  25. data/lib/mcollective/pluginpackager/forge_packager.rb +1 -1
  26. data/lib/mcollective/rpc/client.rb +4 -2
  27. data/lib/mcollective/util.rb +2 -4
  28. data/lib/mcollective/util/choria.rb +14 -8
  29. data/lib/mcollective/util/tasks_support.rb +16 -2
  30. metadata +9 -29
  31. data/lib/mcollective/data.rb +0 -96
  32. data/lib/mcollective/data/agent_data.ddl +0 -22
  33. data/lib/mcollective/data/agent_data.rb +0 -17
  34. data/lib/mcollective/data/base.rb +0 -68
  35. data/lib/mcollective/data/bolt_task_data.ddl +0 -90
  36. data/lib/mcollective/data/bolt_task_data.rb +0 -32
  37. data/lib/mcollective/data/collective_data.ddl +0 -20
  38. data/lib/mcollective/data/collective_data.rb +0 -9
  39. data/lib/mcollective/data/fact_data.ddl +0 -28
  40. data/lib/mcollective/data/fact_data.rb +0 -55
  41. data/lib/mcollective/data/fstat_data.ddl +0 -89
  42. data/lib/mcollective/data/fstat_data.rb +0 -54
  43. data/lib/mcollective/data/result.rb +0 -50
  44. data/lib/mcollective/ddl/dataddl.rb +0 -56
  45. data/lib/mcollective/discovery/choria.rb +0 -223
  46. data/lib/mcollective/discovery/flatfile.rb +0 -47
  47. data/lib/mcollective/discovery/stdin.ddl +0 -11
  48. data/lib/mcollective/discovery/stdin.rb +0 -67
  49. data/lib/mcollective/generators.rb +0 -7
  50. data/lib/mcollective/generators/agent_generator.rb +0 -50
  51. data/lib/mcollective/generators/base.rb +0 -45
  52. data/lib/mcollective/generators/data_generator.rb +0 -50
  53. data/lib/mcollective/generators/templates/action_snippet.erb +0 -13
  54. data/lib/mcollective/generators/templates/data_input_snippet.erb +0 -7
  55. data/lib/mcollective/generators/templates/ddl.erb +0 -8
  56. data/lib/mcollective/generators/templates/plugin.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,7 +0,0 @@
1
- module MCollective
2
- module Generators
3
- require "mcollective/generators/base"
4
- require "mcollective/generators/data_generator"
5
- require "mcollective/generators/agent_generator"
6
- end
7
- end
@@ -1,50 +0,0 @@
1
- module MCollective
2
- module Generators
3
- class AgentGenerator < Base
4
- attr_accessor :ddl, :content
5
-
6
- def initialize(plugin_name, actions=[], 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
- @plugin_name = plugin_name
11
- @actions = actions || []
12
- @ddl = create_ddl
13
- @mod_name = "Agent"
14
- @pclass = "RPC::Agent"
15
- @content = create_plugin_content
16
- @plugin = create_plugin_string
17
- write_plugins
18
- end
19
-
20
- def create_ddl
21
- action_text = ""
22
- @actions.each_with_index do |action, i|
23
- action_text += "action \"#{action}\", :description => \"%ACTIONDESCRIPTION%\" do\n"
24
- action_text += action_help if i == 0
25
- action_text += "end\n"
26
- action_text += "\n" unless @actions.size == (i + 1)
27
- end
28
- # Use inherited method to create metadata part of the ddl
29
- create_metadata_string + action_text
30
- end
31
-
32
- def create_plugin_content
33
- content_text = ""
34
-
35
- # Add actions to agent file
36
- @actions.each_with_index do |action, i|
37
- content_text += "%6s%s" % [" ", "action \"#{action}\" do\n"]
38
- content_text += "%6s%s" % [" ", "end\n"]
39
- content_text += "\n" unless @actions.size == (i + 1)
40
- end
41
- content_text
42
- end
43
-
44
- def action_help
45
- action_snippet = File.read(File.join(File.dirname(__FILE__), "templates", "action_snippet.erb"))
46
- ERB.new(action_snippet).result
47
- end
48
- end
49
- end
50
- end
@@ -1,45 +0,0 @@
1
- module MCollective
2
- module Generators
3
- class Base
4
- attr_accessor :meta, :plugin_name, :mod_name
5
-
6
- def initialize(name, description, author, license, version, url, timeout)
7
- @meta = {:name => name,
8
- :description => description,
9
- :author => author,
10
- :license => license,
11
- :version => version,
12
- :url => url,
13
- :timeout => timeout}
14
- end
15
-
16
- def create_metadata_string
17
- ddl_template = File.read(File.join(File.dirname(__FILE__), "templates", "ddl.erb"))
18
- ERB.new(ddl_template, nil, "-").result(binding)
19
- end
20
-
21
- def create_plugin_string
22
- plugin_template = File.read(File.join(File.dirname(__FILE__), "templates", "plugin.erb"))
23
- ERB.new(plugin_template, nil, "-").result(binding)
24
- end
25
-
26
- def write_plugins
27
- Dir.mkdir @plugin_name
28
- dirname = File.join(@plugin_name, @mod_name.downcase)
29
- Dir.mkdir dirname
30
- puts "Created plugin directory : #{@plugin_name}"
31
-
32
- File.open(File.join(dirname, "#{@plugin_name}.ddl"), "w") {|f| f.puts @ddl}
33
- puts "Created DDL file : #{File.join(dirname, "#{@plugin_name}.ddl")}"
34
-
35
- File.open(File.join(dirname, "#{@plugin_name}.rb"), "w") {|f| f.puts @plugin}
36
- puts "Created #{@mod_name} file : #{File.join(dirname, "#{@plugin_name}.rb")}"
37
- rescue Errno::EEXIST
38
- raise "cannot generate '#{@plugin_name}' : plugin directory already exists."
39
- rescue Exception => e # rubocop:disable Lint/RescueException
40
- FileUtils.rm_rf(@plugin_name) if File.directory?(@plugin_name)
41
- raise "cannot generate plugin - #{e}"
42
- end
43
- end
44
- end
45
- 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
@@ -1,13 +0,0 @@
1
- # Example Input
2
- input :name,
3
- :prompt => "%PROMPT%",
4
- :description => "%DESCRIPTION%",
5
- :type => %TYPE%,
6
- :validation => '%VALIDATION%',
7
- :optional => %OPTIONAL%,
8
- :maxlength => %MAXLENGTH%
9
-
10
- # Example output
11
- output :name,
12
- :description => "%DESCRIPTION%",
13
- :display_as => "%DISPLAYAS%"
@@ -1,7 +0,0 @@
1
- input :query,
2
- :prompt => "%PROMP%",
3
- :description => "%DESCRIPTION%",
4
- :type => %TYPE%,
5
- :validation => %VALIDATION%,
6
- :maxlength => %MAXLENGTH%
7
-
@@ -1,8 +0,0 @@
1
- metadata :name => "<%= meta[:name] || "%FULLNANE%" -%>",
2
- :description => "<%= meta[:description] || "%DESCRIPTION%" -%>",
3
- :author => "<%= meta[:author] || "%AUTHOR%" -%>",
4
- :license => "<%= meta[:license] || "%LICENSE%" -%>",
5
- :version => "<%= meta[:version] || "%VERSION%" -%>",
6
- :url => "<%= meta[:url] || "%URL%" -%>",
7
- :timeout => <%= meta[:timeout] || "%TIMEOUT%" %>
8
-
@@ -1,7 +0,0 @@
1
- module MCollective
2
- module <%= @mod_name%>
3
- class <%= @plugin_name.capitalize -%><<%= @pclass%>
4
- <%= @content%>
5
- end
6
- end
7
- end