mcollective-client 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/lib/mcollective/agent/discovery.rb +37 -0
  2. data/lib/mcollective/agent/rpcutil.ddl +220 -0
  3. data/lib/mcollective/agent/rpcutil.rb +108 -0
  4. data/lib/mcollective/aggregate/average.ddl +33 -0
  5. data/lib/mcollective/aggregate/average.rb +29 -0
  6. data/lib/mcollective/aggregate/result.rb +3 -3
  7. data/lib/mcollective/aggregate/sum.ddl +33 -0
  8. data/lib/mcollective/aggregate/sum.rb +18 -0
  9. data/lib/mcollective/aggregate/summary.ddl +33 -0
  10. data/lib/mcollective/aggregate/summary.rb +53 -0
  11. data/lib/mcollective/aggregate.rb +2 -2
  12. data/lib/mcollective/application/completion.rb +104 -0
  13. data/lib/mcollective/application/facts.rb +62 -0
  14. data/lib/mcollective/application/find.rb +21 -0
  15. data/lib/mcollective/application/help.rb +28 -0
  16. data/lib/mcollective/application/inventory.rb +344 -0
  17. data/lib/mcollective/application/ping.rb +77 -0
  18. data/lib/mcollective/application/plugin.rb +369 -0
  19. data/lib/mcollective/application/rpc.rb +121 -0
  20. data/lib/mcollective/application.rb +2 -0
  21. data/lib/mcollective/audit/logfile.rb +26 -0
  22. data/lib/mcollective/config.rb +16 -9
  23. data/lib/mcollective/connector/activemq.ddl +9 -0
  24. data/lib/mcollective/connector/activemq.rb +572 -0
  25. data/lib/mcollective/connector/rabbitmq.ddl +9 -0
  26. data/lib/mcollective/connector/rabbitmq.rb +484 -0
  27. data/lib/mcollective/connector.rb +1 -1
  28. data/lib/mcollective/data/agent_data.ddl +22 -0
  29. data/lib/mcollective/data/agent_data.rb +17 -0
  30. data/lib/mcollective/data/collective_data.ddl +20 -0
  31. data/lib/mcollective/data/collective_data.rb +9 -0
  32. data/lib/mcollective/data/fact_data.ddl +28 -0
  33. data/lib/mcollective/data/fact_data.rb +55 -0
  34. data/lib/mcollective/data/fstat_data.ddl +89 -0
  35. data/lib/mcollective/data/fstat_data.rb +56 -0
  36. data/lib/mcollective/data.rb +2 -2
  37. data/lib/mcollective/ddl.rb +4 -4
  38. data/lib/mcollective/discovery/flatfile.ddl +11 -0
  39. data/lib/mcollective/discovery/flatfile.rb +48 -0
  40. data/lib/mcollective/discovery/mc.ddl +11 -0
  41. data/lib/mcollective/discovery/mc.rb +30 -0
  42. data/lib/mcollective/discovery/stdin.ddl +11 -0
  43. data/lib/mcollective/discovery/stdin.rb +66 -0
  44. data/lib/mcollective/facts/yaml_facts.rb +61 -0
  45. data/lib/mcollective/facts.rb +1 -1
  46. data/lib/mcollective/generators.rb +3 -3
  47. data/lib/mcollective/logger.rb +1 -1
  48. data/lib/mcollective/matcher/scanner.rb +1 -1
  49. data/lib/mcollective/matcher.rb +2 -2
  50. data/lib/mcollective/pluginpackager/debpackage_packager.rb +237 -0
  51. data/lib/mcollective/pluginpackager/modulepackage_packager.rb +127 -0
  52. data/lib/mcollective/pluginpackager/ospackage_packager.rb +59 -0
  53. data/lib/mcollective/pluginpackager/rpmpackage_packager.rb +180 -0
  54. data/lib/mcollective/pluginpackager/templates/debian/Makefile.erb +7 -0
  55. data/lib/mcollective/pluginpackager/templates/debian/changelog.erb +5 -0
  56. data/lib/mcollective/pluginpackager/templates/debian/compat.erb +1 -0
  57. data/lib/mcollective/pluginpackager/templates/debian/control.erb +15 -0
  58. data/lib/mcollective/pluginpackager/templates/debian/copyright.erb +8 -0
  59. data/lib/mcollective/pluginpackager/templates/debian/rules.erb +6 -0
  60. data/lib/mcollective/pluginpackager/templates/module/Modulefile.erb +5 -0
  61. data/lib/mcollective/pluginpackager/templates/module/README.md.erb +37 -0
  62. data/lib/mcollective/pluginpackager/templates/module/_manifest.pp.erb +9 -0
  63. data/lib/mcollective/pluginpackager/templates/redhat/rpm_spec.erb +63 -0
  64. data/lib/mcollective/pluginpackager.rb +2 -2
  65. data/lib/mcollective/registration/agentlist.rb +10 -0
  66. data/lib/mcollective/registration.rb +1 -1
  67. data/lib/mcollective/rpc/stats.rb +0 -1
  68. data/lib/mcollective/rpc.rb +11 -11
  69. data/lib/mcollective/security/aes_security.rb +394 -0
  70. data/lib/mcollective/security/psk.rb +117 -0
  71. data/lib/mcollective/security/ssl.rb +328 -0
  72. data/lib/mcollective/security.rb +1 -1
  73. data/lib/mcollective/util.rb +18 -18
  74. data/lib/mcollective/validator/array_validator.ddl +7 -0
  75. data/lib/mcollective/validator/array_validator.rb +9 -0
  76. data/lib/mcollective/validator/ipv4address_validator.ddl +7 -0
  77. data/lib/mcollective/validator/ipv4address_validator.rb +16 -0
  78. data/lib/mcollective/validator/ipv6address_validator.ddl +7 -0
  79. data/lib/mcollective/validator/ipv6address_validator.rb +16 -0
  80. data/lib/mcollective/validator/length_validator.ddl +7 -0
  81. data/lib/mcollective/validator/length_validator.rb +11 -0
  82. data/lib/mcollective/validator/regex_validator.ddl +7 -0
  83. data/lib/mcollective/validator/regex_validator.rb +9 -0
  84. data/lib/mcollective/validator/shellsafe_validator.ddl +7 -0
  85. data/lib/mcollective/validator/shellsafe_validator.rb +13 -0
  86. data/lib/mcollective/validator/typecheck_validator.ddl +7 -0
  87. data/lib/mcollective/validator/typecheck_validator.rb +28 -0
  88. data/lib/mcollective.rb +31 -31
  89. data/spec/spec_helper.rb +0 -5
  90. data/spec/unit/{plugins/mcollective → mcollective}/agent/rpcutil_spec.rb +1 -1
  91. data/spec/unit/{agents_spec.rb → mcollective/agents_spec.rb} +0 -0
  92. data/spec/unit/{plugins/mcollective → mcollective}/aggregate/average_spec.rb +1 -1
  93. data/spec/unit/{aggregate → mcollective/aggregate}/base_spec.rb +0 -0
  94. data/spec/unit/{aggregate → mcollective/aggregate}/result/base_spec.rb +0 -0
  95. data/spec/unit/{aggregate → mcollective/aggregate}/result/collection_result_spec.rb +0 -0
  96. data/spec/unit/{aggregate → mcollective/aggregate}/result/numeric_result_spec.rb +0 -0
  97. data/spec/unit/{plugins/mcollective → mcollective}/aggregate/sum_spec.rb +1 -1
  98. data/spec/unit/{plugins/mcollective → mcollective}/aggregate/summary_spec.rb +1 -1
  99. data/spec/unit/{aggregate_spec.rb → mcollective/aggregate_spec.rb} +0 -0
  100. data/spec/unit/{plugins/mcollective → mcollective}/application/plugin_spec.rb +1 -1
  101. data/spec/unit/{application_spec.rb → mcollective/application_spec.rb} +0 -0
  102. data/spec/unit/{applications_spec.rb → mcollective/applications_spec.rb} +1 -1
  103. data/spec/unit/{array_spec.rb → mcollective/array_spec.rb} +0 -0
  104. data/spec/unit/{plugins/mcollective → mcollective}/audit/logfile_spec.rb +1 -1
  105. data/spec/unit/{cache_spec.rb → mcollective/cache_spec.rb} +0 -0
  106. data/spec/unit/{client_spec.rb → mcollective/client_spec.rb} +0 -0
  107. data/spec/unit/{config_spec.rb → mcollective/config_spec.rb} +12 -7
  108. data/spec/unit/{plugins/mcollective → mcollective}/connector/activemq_spec.rb +1 -1
  109. data/spec/unit/{connector → mcollective/connector}/base_spec.rb +0 -0
  110. data/spec/unit/{plugins/mcollective → mcollective}/connector/rabbitmq_spec.rb +1 -1
  111. data/spec/unit/{plugins/mcollective → mcollective}/data/agent_data_spec.rb +1 -1
  112. data/spec/unit/{data → mcollective/data}/base_spec.rb +0 -0
  113. data/spec/unit/{plugins/mcollective → mcollective}/data/collective_data_spec.rb +1 -1
  114. data/spec/unit/{plugins/mcollective → mcollective}/data/fact_data_spec.rb +1 -1
  115. data/spec/unit/{plugins/mcollective → mcollective}/data/fstat_data_spec.rb +1 -1
  116. data/spec/unit/{data → mcollective/data}/result_spec.rb +0 -0
  117. data/spec/unit/{data_spec.rb → mcollective/data_spec.rb} +0 -0
  118. data/spec/unit/{ddl → mcollective/ddl}/agentddl_spec.rb +0 -0
  119. data/spec/unit/{ddl → mcollective/ddl}/base_spec.rb +0 -0
  120. data/spec/unit/{ddl → mcollective/ddl}/dataddl_spec.rb +0 -0
  121. data/spec/unit/{ddl → mcollective/ddl}/discoveryddl_spec.rb +0 -0
  122. data/spec/unit/{ddl_spec.rb → mcollective/ddl_spec.rb} +0 -0
  123. data/spec/unit/{plugins/mcollective → mcollective}/discovery/flatfile_spec.rb +1 -1
  124. data/spec/unit/{plugins/mcollective → mcollective}/discovery/mc_spec.rb +1 -1
  125. data/spec/unit/{plugins/mcollective → mcollective}/discovery/stdin_spec.rb +1 -1
  126. data/spec/unit/{discovery_spec.rb → mcollective/discovery_spec.rb} +0 -0
  127. data/spec/unit/{facts → mcollective/facts}/base_spec.rb +0 -0
  128. data/spec/unit/{plugins/mcollective → mcollective}/facts/yaml_facts_spec.rb +1 -1
  129. data/spec/unit/{facts_spec.rb → mcollective/facts_spec.rb} +0 -0
  130. data/spec/unit/{generators → mcollective/generators}/agent_generator_spec.rb +0 -0
  131. data/spec/unit/{generators → mcollective/generators}/base_spec.rb +0 -0
  132. data/spec/unit/{generators → mcollective/generators}/data_generator_spec.rb +0 -0
  133. data/spec/unit/{generators → mcollective/generators}/snippets/agent_ddl +0 -0
  134. data/spec/unit/{generators → mcollective/generators}/snippets/data_ddl +0 -0
  135. data/spec/unit/{log_spec.rb → mcollective/log_spec.rb} +0 -0
  136. data/spec/unit/{logger → mcollective/logger}/base_spec.rb +0 -0
  137. data/spec/unit/{logger → mcollective/logger}/console_logger_spec.rb +0 -0
  138. data/spec/unit/{logger → mcollective/logger}/file_logger_spec.rb +0 -0
  139. data/spec/unit/{logger → mcollective/logger}/syslog_logger_spec.rb +0 -0
  140. data/spec/unit/{matcher → mcollective/matcher}/parser_spec.rb +0 -0
  141. data/spec/unit/{matcher → mcollective/matcher}/scanner_spec.rb +0 -0
  142. data/spec/unit/{matcher_spec.rb → mcollective/matcher_spec.rb} +0 -0
  143. data/spec/unit/{message_spec.rb → mcollective/message_spec.rb} +0 -0
  144. data/spec/unit/{monkey_patches_spec.rb → mcollective/monkey_patches_spec.rb} +0 -0
  145. data/spec/unit/{optionparser_spec.rb → mcollective/optionparser_spec.rb} +0 -0
  146. data/spec/unit/{plugins/mcollective → mcollective}/packagers/debpackage_packager_spec.rb +1 -1
  147. data/spec/unit/{plugins/mcollective → mcollective}/packagers/modulepackage_packager_spec.rb +1 -1
  148. data/spec/unit/{plugins/mcollective → mcollective}/packagers/ospackage_spec.rb +1 -1
  149. data/spec/unit/{plugins/mcollective → mcollective}/packagers/rpmpackage_packager_spec.rb +1 -1
  150. data/spec/unit/{pluginmanager_spec.rb → mcollective/pluginmanager_spec.rb} +0 -0
  151. data/spec/unit/{pluginpackager → mcollective/pluginpackager}/agent_definition_spec.rb +0 -0
  152. data/spec/unit/{pluginpackager → mcollective/pluginpackager}/standard_definition_spec.rb +0 -0
  153. data/spec/unit/{pluginpackager_spec.rb → mcollective/pluginpackager_spec.rb} +0 -0
  154. data/spec/unit/{registration → mcollective/registration}/base_spec.rb +0 -0
  155. data/spec/unit/{rpc → mcollective/rpc}/actionrunner_spec.rb +0 -0
  156. data/spec/unit/{rpc → mcollective/rpc}/agent_spec.rb +0 -0
  157. data/spec/unit/{rpc → mcollective/rpc}/client_spec.rb +0 -0
  158. data/spec/unit/{rpc → mcollective/rpc}/helpers_spec.rb +0 -0
  159. data/spec/unit/{rpc → mcollective/rpc}/reply_spec.rb +0 -0
  160. data/spec/unit/{rpc → mcollective/rpc}/request_spec.rb +0 -0
  161. data/spec/unit/{rpc → mcollective/rpc}/result_spec.rb +0 -0
  162. data/spec/unit/{rpc → mcollective/rpc}/stats_spec.rb +0 -0
  163. data/spec/unit/{rpc_spec.rb → mcollective/rpc_spec.rb} +0 -0
  164. data/spec/unit/{runner_spec.rb → mcollective/runner_spec.rb} +0 -0
  165. data/spec/unit/{runnerstats_spec.rb → mcollective/runnerstats_spec.rb} +0 -0
  166. data/spec/unit/{plugins/mcollective → mcollective}/security/aes_security_spec.rb +1 -1
  167. data/spec/unit/{security → mcollective/security}/base_spec.rb +0 -0
  168. data/spec/unit/{plugins/mcollective → mcollective}/security/psk_spec.rb +1 -1
  169. data/spec/unit/{shell_spec.rb → mcollective/shell_spec.rb} +0 -0
  170. data/spec/unit/{ssl_spec.rb → mcollective/ssl_spec.rb} +12 -12
  171. data/spec/unit/{string_spec.rb → mcollective/string_spec.rb} +0 -0
  172. data/spec/unit/{symbol_spec.rb → mcollective/symbol_spec.rb} +0 -0
  173. data/spec/unit/{unix_daemon_spec.rb → mcollective/unix_daemon_spec.rb} +0 -0
  174. data/spec/unit/{util_spec.rb → mcollective/util_spec.rb} +28 -6
  175. data/spec/unit/{plugins/mcollective → mcollective}/validator/array_validator_spec.rb +1 -1
  176. data/spec/unit/{plugins/mcollective → mcollective}/validator/ipv4address_validator_spec.rb +1 -1
  177. data/spec/unit/{plugins/mcollective → mcollective}/validator/ipv6address_validator_spec.rb +1 -1
  178. data/spec/unit/{plugins/mcollective → mcollective}/validator/length_validator_spec.rb +1 -1
  179. data/spec/unit/{plugins/mcollective → mcollective}/validator/regex_validator_spec.rb +1 -1
  180. data/spec/unit/{plugins/mcollective → mcollective}/validator/shellsafe_validator_spec.rb +1 -1
  181. data/spec/unit/{plugins/mcollective → mcollective}/validator/typecheck_validator_spec.rb +1 -1
  182. data/spec/unit/{validator_spec.rb → mcollective/validator_spec.rb} +1 -1
  183. data/spec/unit/{vendor_spec.rb → mcollective/vendor_spec.rb} +2 -2
  184. data/spec/unit/{windows_daemon_spec.rb → mcollective/windows_daemon_spec.rb} +0 -0
  185. metadata +361 -284
  186. checksums.yaml +0 -7
@@ -0,0 +1,89 @@
1
+ metadata :name => "File Stat",
2
+ :description => "Retrieve file stat data for a given file",
3
+ :author => "R.I.Pienaar <rip@devco.net>",
4
+ :license => "ASL 2.0",
5
+ :version => "1.0",
6
+ :url => "http://marionette-collective.org/",
7
+ :timeout => 1
8
+
9
+ dataquery :description => "File stat information" do
10
+ input :query,
11
+ :prompt => "File Name",
12
+ :description => "Valid File Name",
13
+ :type => :string,
14
+ :validation => /.+/,
15
+ :maxlength => 120
16
+
17
+ output :name,
18
+ :description => "File name",
19
+ :display_as => "Name"
20
+
21
+ output :output,
22
+ :description => "Human readable information about the file",
23
+ :display_as => "Status"
24
+
25
+ output :present,
26
+ :description => "Indicates if the file exist using 0 or 1",
27
+ :display_as => "Present"
28
+
29
+ output :size,
30
+ :description => "File size",
31
+ :display_as => "Size"
32
+
33
+ output :mode,
34
+ :description => "File mode",
35
+ :display_as => "Mode"
36
+
37
+ output :md5,
38
+ :description => "File MD5 digest",
39
+ :display_as => "MD5"
40
+
41
+ output :mtime,
42
+ :description => "File modification time",
43
+ :display_as => "Modification time"
44
+
45
+ output :ctime,
46
+ :description => "File change time",
47
+ :display_as => "Change time"
48
+
49
+ output :atime,
50
+ :description => "File access time",
51
+ :display_as => "Access time"
52
+
53
+ output :mtime_seconds,
54
+ :description => "File modification time in seconds",
55
+ :display_as => "Modification time"
56
+
57
+ output :ctime_seconds,
58
+ :description => "File change time in seconds",
59
+ :display_as => "Change time"
60
+
61
+ output :atime_seconds,
62
+ :description => "File access time in seconds",
63
+ :display_as => "Access time"
64
+
65
+ output :mtime_age,
66
+ :description => "File modification age in seconds",
67
+ :display_as => "Modification age"
68
+
69
+ output :ctime_age,
70
+ :description => "File change age in seconds",
71
+ :display_as => "Change age"
72
+
73
+ output :atime_age,
74
+ :description => "File access age in seconds",
75
+ :display_as => "Access age"
76
+
77
+ output :uid,
78
+ :description => "File owner",
79
+ :display_as => "Owner"
80
+
81
+ output :gid,
82
+ :description => "File group",
83
+ :display_as => "Group"
84
+
85
+ output :type,
86
+ :description => "File type",
87
+ :display_as => "Type"
88
+ end
89
+
@@ -0,0 +1,56 @@
1
+ module MCollective
2
+ module Data
3
+ class Fstat_data<Base
4
+ query do |file|
5
+ result[:name] = file
6
+ result[:output] = "not present"
7
+ result[:type] = "unknown"
8
+ result[:mode] = "0000"
9
+ result[:present] = 0
10
+ result[:size] = 0
11
+ result[:mtime] = 0
12
+ result[:ctime] = 0
13
+ result[:atime] = 0
14
+ result[:mtime_seconds] = 0
15
+ result[:ctime_seconds] = 0
16
+ result[:atime_seconds] = 0
17
+ result[:md5] = 0
18
+ result[:uid] = 0
19
+ result[:gid] = 0
20
+
21
+
22
+ if File.exists?(file)
23
+ result[:output] = "present"
24
+ result[:present] = 1
25
+
26
+ if File.symlink?(file)
27
+ stat = File.lstat(file)
28
+ else
29
+ stat = File.stat(file)
30
+ end
31
+
32
+ [:size, :uid, :gid].each do |item|
33
+ result[item] = stat.send(item)
34
+ end
35
+
36
+ [:mtime, :ctime, :atime].each do |item|
37
+ result[item] = stat.send(item).strftime("%F %T")
38
+ result["#{item}_seconds".to_sym] = stat.send(item).to_i
39
+ result["#{item}_age".to_sym] = Time.now.to_i - stat.send(item).to_i
40
+ end
41
+
42
+ result[:mode] = "%o" % [stat.mode]
43
+ result[:md5] = Digest::MD5.hexdigest(File.read(file)) if stat.file?
44
+
45
+ result[:type] = "directory" if stat.directory?
46
+ result[:type] = "file" if stat.file?
47
+ result[:type] = "symlink" if stat.symlink?
48
+ result[:type] = "socket" if stat.socket?
49
+ result[:type] = "chardev" if stat.chardev?
50
+ result[:type] = "blockdev" if stat.blockdev?
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
@@ -1,7 +1,7 @@
1
1
  module MCollective
2
2
  module Data
3
- autoload :Base, "mcollective/data/base"
4
- autoload :Result, "mcollective/data/result"
3
+ require "mcollective/data/base"
4
+ require "mcollective/data/result"
5
5
 
6
6
  def self.load_data_sources
7
7
  PluginManager.find_and_load("data")
@@ -48,10 +48,10 @@ module MCollective
48
48
  # content though so you add, do not remove. See the AgentDDL class for an example
49
49
  # where agents want a :required argument to be always set.
50
50
  module DDL
51
- autoload :Base, "mcollective/ddl/base"
52
- autoload :AgentDDL, "mcollective/ddl/agentddl"
53
- autoload :DataDDL, "mcollective/ddl/dataddl"
54
- autoload :DiscoveryDDL, "mcollective/ddl/discoveryddl"
51
+ require "mcollective/ddl/base"
52
+ require "mcollective/ddl/agentddl"
53
+ require "mcollective/ddl/dataddl"
54
+ require "mcollective/ddl/discoveryddl"
55
55
 
56
56
  # There used to be only one big nasty DDL class with a bunch of mashed
57
57
  # together behaviors. It's been around for ages and we would rather not
@@ -0,0 +1,11 @@
1
+ metadata :name => "flatfile",
2
+ :description => "Flatfile based discovery for node identities",
3
+ :author => "R.I.Pienaar <rip@devco.net>",
4
+ :license => "ASL 2.0",
5
+ :version => "0.1",
6
+ :url => "http://marionette-collective.org/",
7
+ :timeout => 0
8
+
9
+ discovery do
10
+ capabilities :identity
11
+ end
@@ -0,0 +1,48 @@
1
+ # discovers against a flatfile instead of the traditional network discovery
2
+ # the flat file must have a node name per line which should match identities
3
+ # as configured
4
+ module MCollective
5
+ class Discovery
6
+ class Flatfile
7
+ def self.discover(filter, timeout, limit=0, client=nil)
8
+ unless client.options[:discovery_options].empty?
9
+ file = client.options[:discovery_options].first
10
+ else
11
+ raise "The flatfile discovery method needs a path to a text file"
12
+ end
13
+
14
+ raise "Cannot read the file %s specified as discovery source" % file unless File.readable?(file)
15
+
16
+ discovered = []
17
+ hosts = []
18
+
19
+ File.readlines(file).each do |host|
20
+ host = host.chomp.strip
21
+ if host.empty? || host.match(/^#/)
22
+ next
23
+ end
24
+ raise 'Identities can only match /^[\w\.\-]+$/' unless host.match(/^[\w\.\-]+$/)
25
+ hosts << host
26
+ end
27
+
28
+ # this plugin only supports identity filters, do regex matches etc against
29
+ # the list found in the flatfile
30
+ if !(filter["identity"].empty?)
31
+ filter["identity"].each do |identity|
32
+ identity = Regexp.new(identity.gsub("\/", "")) if identity.match("^/")
33
+
34
+ if identity.is_a?(Regexp)
35
+ discovered = hosts.grep(identity)
36
+ elsif hosts.include?(identity)
37
+ discovered << identity
38
+ end
39
+ end
40
+ else
41
+ discovered = hosts
42
+ end
43
+
44
+ discovered
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,11 @@
1
+ metadata :name => "mc",
2
+ :description => "MCollective Broadcast based discovery",
3
+ :author => "R.I.Pienaar <rip@devco.net>",
4
+ :license => "ASL 2.0",
5
+ :version => "0.1",
6
+ :url => "http://marionette-collective.org/",
7
+ :timeout => 2
8
+
9
+ discovery do
10
+ capabilities [:classes, :facts, :identity, :agents, :compound]
11
+ end
@@ -0,0 +1,30 @@
1
+ module MCollective
2
+ class Discovery
3
+ class Mc
4
+ def self.discover(filter, timeout, limit, client)
5
+ begin
6
+ hosts = []
7
+ Timeout.timeout(timeout) do
8
+ reqid = client.sendreq("ping", "discovery", filter)
9
+ Log.debug("Waiting #{timeout} seconds for discovery replies to request #{reqid}")
10
+
11
+ loop do
12
+ reply = client.receive(reqid)
13
+ Log.debug("Got discovery reply from #{reply.payload[:senderid]}")
14
+ hosts << reply.payload[:senderid]
15
+
16
+ return hosts if limit > 0 && hosts.size == limit
17
+ end
18
+ end
19
+ rescue Timeout::Error => e
20
+ rescue Exception => e
21
+ raise
22
+ ensure
23
+ client.unsubscribe("discovery", :reply)
24
+ end
25
+
26
+ hosts
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ metadata :name => "stdin",
2
+ :description => "STDIN based discovery for node identities",
3
+ :author => "Tomas Doran <bobtfish@bobtfish.net.net>",
4
+ :license => "ASL 2.0",
5
+ :version => "0.1",
6
+ :url => "http://marionette-collective.org/",
7
+ :timeout => 0
8
+
9
+ discovery do
10
+ capabilities :identity
11
+ end
@@ -0,0 +1,66 @@
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
+ unless client.options[:discovery_options].empty?
11
+ type = client.options[:discovery_options].first.downcase
12
+ else
13
+ type = 'auto'
14
+ end
15
+
16
+ discovered = []
17
+
18
+ file = STDIN.read
19
+
20
+ if file =~ /^\s*$/
21
+ raise("data piped on STDIN contained only whitespace - could not discover hosts from it.")
22
+ end
23
+
24
+ if type == 'auto'
25
+ if file =~ /^\s*\[/
26
+ type = 'json'
27
+ else
28
+ type = 'text'
29
+ end
30
+ end
31
+
32
+ if type == 'json'
33
+ hosts = MCollective::RPC::Helpers.extract_hosts_from_json(file)
34
+ elsif type == 'text'
35
+ hosts = file.split("\n")
36
+ else
37
+ raise("stdin discovery plugin only knows the types auto/text/json, not \"#{type}\"")
38
+ end
39
+
40
+ hosts.map do |host|
41
+ raise 'Identities can only match /\w\.\-/' unless host.match(/^[\w\.\-]+$/)
42
+ host
43
+ end
44
+
45
+ # this plugin only supports identity filters, do regex matches etc against
46
+ # the list found in the flatfile
47
+ unless filter["identity"].empty?
48
+ filter["identity"].each do |identity|
49
+ identity = Regexp.new(identity.gsub("\/", "")) if identity.match("^/")
50
+
51
+ if identity.is_a?(Regexp)
52
+ discovered = hosts.grep(identity)
53
+ elsif hosts.include?(identity)
54
+ discovered << identity
55
+ end
56
+ end
57
+ else
58
+ discovered = hosts
59
+ end
60
+
61
+ discovered
62
+ end
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,61 @@
1
+ module MCollective
2
+ module Facts
3
+ require 'yaml'
4
+
5
+ # A factsource that reads a hash of facts from a YAML file
6
+ #
7
+ # Multiple files can be specified seperated with a : in the
8
+ # config file, they will be merged with later files overriding
9
+ # earlier ones in the list.
10
+ class Yaml_facts<Base
11
+ def initialize
12
+ @yaml_file_mtimes = {}
13
+
14
+ super
15
+ end
16
+
17
+ def load_facts_from_source
18
+ config = Config.instance
19
+
20
+ fact_files = config.pluginconf["yaml"].split(File::PATH_SEPARATOR)
21
+ facts = {}
22
+
23
+ fact_files.each do |file|
24
+ begin
25
+ if File.exist?(file)
26
+ facts.merge!(YAML.load(File.read(file)))
27
+ else
28
+ raise("Can't find YAML file to load: #{file}")
29
+ end
30
+ rescue Exception => e
31
+ Log.error("Failed to load yaml facts from #{file}: #{e.class}: #{e}")
32
+ end
33
+ end
34
+
35
+ facts
36
+ end
37
+
38
+ # force fact reloads when the mtime on the yaml file change
39
+ def force_reload?
40
+ config = Config.instance
41
+
42
+ fact_files = config.pluginconf["yaml"].split(File::PATH_SEPARATOR)
43
+
44
+ fact_files.each do |file|
45
+ @yaml_file_mtimes[file] ||= File.stat(file).mtime
46
+ mtime = File.stat(file).mtime
47
+
48
+ if mtime > @yaml_file_mtimes[file]
49
+ @yaml_file_mtimes[file] = mtime
50
+
51
+ Log.debug("Forcing fact reload due to age of #{file}")
52
+
53
+ return true
54
+ end
55
+ end
56
+
57
+ false
58
+ end
59
+ end
60
+ end
61
+ end
@@ -17,7 +17,7 @@ module MCollective
17
17
  #
18
18
  # method that should return a hash of facts.
19
19
  module Facts
20
- autoload :Base, "mcollective/facts/base"
20
+ require "mcollective/facts/base"
21
21
 
22
22
  @@config = nil
23
23
 
@@ -1,7 +1,7 @@
1
1
  module MCollective
2
2
  module Generators
3
- autoload :Base, "mcollective/generators/base.rb"
4
- autoload :DataGenerator, "mcollective/generators/data_generator.rb"
5
- autoload :AgentGenerator, "mcollective/generators/agent_generator.rb"
3
+ require "mcollective/generators/base.rb"
4
+ require "mcollective/generators/data_generator.rb"
5
+ require "mcollective/generators/agent_generator.rb"
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module MCollective
2
2
  module Logger
3
- autoload :Base, "mcollective/logger/base"
3
+ require "mcollective/logger/base"
4
4
  end
5
5
  end
@@ -152,7 +152,7 @@ module MCollective
152
152
  else
153
153
  if func
154
154
  if current_token_value.match(/^.+?\((\s*(')[^']*(')\s*(,\s*(')[^']*('))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/) ||
155
- current_token_value.match(/^.+?\((\s*(")[^"]*(")\s*(,\s*(")[^"]*("))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/)
155
+ current_token_value.match(/^.+?\((\s*(")[^"]*(")\s*(,\s*(")[^"]*("))*)?\)(\.[a-zA-Z0-9_]+)?((!=|<=|>=|=|>|<).+)?$/)
156
156
  return "fstatement", current_token_value
157
157
  else
158
158
  return "bad_token", [@token_index - current_token_value.size + 1, @token_index]
@@ -10,8 +10,8 @@ module MCollective
10
10
  # char = A-Z | a-z | < | > | => | =< | _ | - |* | / { A-Z | a-z | < | > | => | =< | _ | - | * | / | }
11
11
  # int = 0|1|2|3|4|5|6|7|8|9{|0|1|2|3|4|5|6|7|8|9|0}
12
12
  module Matcher
13
- autoload :Parser, "mcollective/matcher/parser"
14
- autoload :Scanner, "mcollective/matcher/scanner"
13
+ require "mcollective/matcher/parser"
14
+ require "mcollective/matcher/scanner"
15
15
 
16
16
  # Helper creates a hash from a function call string
17
17
  def self.create_function_hash(function_call)