mcollective-client 2.7.0 → 2.8.0

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 (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,37 @@
1
+ module MCollective
2
+ module Agent
3
+ # Discovery agent for The Marionette Collective
4
+ #
5
+ # Released under the Apache License, Version 2
6
+ class Discovery
7
+ attr_reader :timeout, :meta
8
+
9
+ def initialize
10
+ config = Config.instance.pluginconf
11
+
12
+ @timeout = 5
13
+ @meta = {:license => "Apache License, Version 2",
14
+ :author => "R.I.Pienaar <rip@devco.net>",
15
+ :timeout => @timeout,
16
+ :name => "Discovery Agent",
17
+ :version => MCollective.version,
18
+ :url => "http://www.marionette-collective.org",
19
+ :description => "MCollective Discovery Agent"}
20
+ end
21
+
22
+ def handlemsg(msg, stomp)
23
+ reply = "unknown request"
24
+
25
+ case msg[:body]
26
+ when "ping"
27
+ reply = "pong"
28
+
29
+ else
30
+ reply = "Unknown Request: #{msg[:body]}"
31
+ end
32
+
33
+ reply
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,220 @@
1
+ metadata :name => "rpcutil",
2
+ :description => "General helpful actions that expose stats and internals to SimpleRPC clients",
3
+ :author => "R.I.Pienaar <rip@devco.net>",
4
+ :license => "Apache License, Version 2.0",
5
+ :version => "1.0",
6
+ :url => "http://marionette-collective.org/",
7
+ :timeout => 10
8
+
9
+ action "collective_info", :description => "Info about the main and sub collectives" do
10
+ display :always
11
+
12
+ output :main_collective,
13
+ :description => "The main Collective",
14
+ :display_as => "Main Collective"
15
+
16
+ output :collectives,
17
+ :description => "All Collectives",
18
+ :display_as => "All Collectives"
19
+
20
+ summarize do
21
+ aggregate summary(:collectives)
22
+ end
23
+ end
24
+
25
+ action "inventory", :description => "System Inventory" do
26
+ display :always
27
+
28
+ output :agents,
29
+ :description => "List of agent names",
30
+ :display_as => "Agents"
31
+
32
+ output :facts,
33
+ :description => "List of facts and values",
34
+ :display_as => "Facts"
35
+
36
+ output :classes,
37
+ :description => "List of classes on the system",
38
+ :display_as => "Classes"
39
+
40
+ output :version,
41
+ :description => "MCollective Version",
42
+ :display_as => "Version"
43
+
44
+ output :main_collective,
45
+ :description => "The main Collective",
46
+ :display_as => "Main Collective"
47
+
48
+ output :collectives,
49
+ :description => "All Collectives",
50
+ :display_as => "All Collectives"
51
+
52
+ output :data_plugins,
53
+ :description => "List of data plugin names",
54
+ :display_as => "Data Plugins"
55
+ end
56
+
57
+ action "get_fact", :description => "Retrieve a single fact from the fact store" do
58
+ display :always
59
+
60
+ input :fact,
61
+ :prompt => "The name of the fact",
62
+ :description => "The fact to retrieve",
63
+ :type => :string,
64
+ :validation => '^[\w\-\.]+$',
65
+ :optional => false,
66
+ :maxlength => 40
67
+
68
+ output :fact,
69
+ :description => "The name of the fact being returned",
70
+ :display_as => "Fact"
71
+
72
+ output :value,
73
+ :description => "The value of the fact",
74
+ :display_as => "Value"
75
+
76
+ summarize do
77
+ aggregate summary(:value)
78
+ end
79
+ end
80
+
81
+ action "get_facts", :description => "Retrieve multiple facts from the fact store" do
82
+ display :always
83
+
84
+ input :facts,
85
+ :prompt => "Comma-separated list of facts",
86
+ :description => "Facts to retrieve",
87
+ :type => :string,
88
+ :validation => '^\s*[\w\.\-]+(\s*,\s*[\w\.\-]+)*$',
89
+ :optional => false,
90
+ :maxlength => 200
91
+
92
+ output :values,
93
+ :description => "List of values of the facts",
94
+ :display_as => "Values"
95
+ end
96
+
97
+ action "daemon_stats", :description => "Get statistics from the running daemon" do
98
+ display :always
99
+
100
+ output :threads,
101
+ :description => "List of threads active in the daemon",
102
+ :display_as => "Threads"
103
+
104
+ output :agents,
105
+ :description => "List of agents loaded",
106
+ :display_as => "Agents"
107
+
108
+ output :pid,
109
+ :description => "Process ID of the daemon",
110
+ :display_as => "PID"
111
+
112
+ output :times,
113
+ :description => "Processor time consumed by the daemon",
114
+ :display_as => "Times"
115
+
116
+ output :validated,
117
+ :description => "Messages that passed security validation",
118
+ :display_as => "Security Validated"
119
+
120
+ output :unvalidated,
121
+ :description => "Messages that failed security validation",
122
+ :display_as => "Failed Security"
123
+
124
+ output :passed,
125
+ :description => "Passed filter checks",
126
+ :display_as => "Passed Filter"
127
+
128
+ output :filtered,
129
+ :description => "Didn't pass filter checks",
130
+ :display_as => "Failed Filter"
131
+
132
+ output :starttime,
133
+ :description => "Time the server started",
134
+ :display_as => "Start Time"
135
+
136
+ output :total,
137
+ :description => "Total messages received",
138
+ :display_as => "Total Messages"
139
+
140
+ output :replies,
141
+ :description => "Replies sent back to clients",
142
+ :display_as => "Replies"
143
+
144
+ output :configfile,
145
+ :description => "Config file used to start the daemon",
146
+ :display_as => "Config File"
147
+
148
+ output :version,
149
+ :description => "MCollective Version",
150
+ :display_as => "Version"
151
+
152
+ output :ttlexpired,
153
+ :description => "Messages that did pass TTL checks",
154
+ :display_as => "TTL Expired"
155
+
156
+ summarize do
157
+ aggregate summary(:version)
158
+ aggregate summary(:agents)
159
+ end
160
+ end
161
+
162
+ action "agent_inventory", :description => "Inventory of all agents on the server" do
163
+ display :always
164
+
165
+ output :agents,
166
+ :description => "List of agents on the server",
167
+ :display_as => "Agents"
168
+ end
169
+
170
+ action "get_config_item", :description => "Get the active value of a specific config property" do
171
+ display :always
172
+
173
+ input :item,
174
+ :prompt => "Configuration Item",
175
+ :description => "The item to retrieve from the server",
176
+ :type => :string,
177
+ :validation => '^.+$',
178
+ :optional => false,
179
+ :maxlength => 50
180
+
181
+ output :item,
182
+ :description => "The config property being retrieved",
183
+ :display_as => "Property"
184
+
185
+ output :value,
186
+ :description => "The value that is in use",
187
+ :display_as => "Value"
188
+
189
+ summarize do
190
+ aggregate summary(:value)
191
+ end
192
+ end
193
+
194
+ action "get_data", :description => "Get data from a data plugin" do
195
+ display :always
196
+
197
+ input :source,
198
+ :prompt => "Data Source",
199
+ :description => "The data plugin to retrieve information from",
200
+ :type => :string,
201
+ :validation => '^\w+$',
202
+ :optional => false,
203
+ :maxlength => 50
204
+
205
+ input :query,
206
+ :prompt => "Query",
207
+ :description => "The query argument to supply to the data plugin",
208
+ :type => :string,
209
+ :validation => '^.+$',
210
+ :optional => true,
211
+ :maxlength => 200
212
+ end
213
+
214
+ action "ping", :description => "Responds to requests for PING with PONG" do
215
+ display :always
216
+
217
+ output :pong,
218
+ :description => "The local timestamp",
219
+ :display_as => "Timestamp"
220
+ end
@@ -0,0 +1,108 @@
1
+ module MCollective
2
+ module Agent
3
+ class Rpcutil<RPC::Agent
4
+ # Basic system inventory, same as the basic discovery agent
5
+ action "inventory" do
6
+ reply[:agents] = Agents.agentlist
7
+ reply[:facts] = PluginManager["facts_plugin"].get_facts
8
+ reply[:version] = MCollective.version
9
+ reply[:classes] = []
10
+ reply[:main_collective] = config.main_collective
11
+ reply[:collectives] = config.collectives
12
+ reply[:data_plugins] = PluginManager.grep(/_data$/)
13
+
14
+ cfile = Config.instance.classesfile
15
+ if File.exist?(cfile)
16
+ reply[:classes] = File.readlines(cfile).map {|i| i.chomp}
17
+ end
18
+ end
19
+
20
+ # Retrieve a single fact from the node
21
+ action "get_fact" do
22
+ reply[:fact] = request[:fact]
23
+ reply[:value] = Facts[request[:fact]]
24
+ end
25
+
26
+ action "get_facts" do
27
+ response = {}
28
+ request[:facts].split(',').map { |x| x.strip }.each do |fact|
29
+ value = Facts[fact]
30
+ response[fact] = value
31
+ end
32
+ reply[:values] = response
33
+ end
34
+
35
+ # Get the global stats for this mcollectied
36
+ action "daemon_stats" do
37
+ stats = PluginManager["global_stats"].to_hash
38
+
39
+ reply[:threads] = stats[:threads]
40
+ reply[:agents] = stats[:agents]
41
+ reply[:pid] = stats[:pid]
42
+ reply[:times] = stats[:times]
43
+ reply[:configfile] = Config.instance.configfile
44
+ reply[:version] = MCollective.version
45
+
46
+ reply.data.merge!(stats[:stats])
47
+ end
48
+
49
+ # Builds an inventory of all agents on teh machine
50
+ # including license, version and timeout information
51
+ action "agent_inventory" do
52
+ reply[:agents] = []
53
+
54
+ Agents.agentlist.sort.each do |target_agent|
55
+ agent = PluginManager["#{target_agent}_agent"]
56
+ actions = agent.methods.grep(/_agent/)
57
+
58
+ agent_data = {:agent => target_agent,
59
+ :license => "unknown",
60
+ :timeout => agent.timeout,
61
+ :description => "unknown",
62
+ :name => target_agent,
63
+ :url => "unknown",
64
+ :version => "unknown",
65
+ :author => "unknown"}
66
+
67
+ agent_data.merge!(agent.meta)
68
+
69
+ reply[:agents] << agent_data
70
+ end
71
+ end
72
+
73
+ # Retrieves a single config property that is in effect
74
+ action "get_config_item" do
75
+ reply.fail! "Unknown config property #{request[:item]}" unless config.respond_to?(request[:item])
76
+
77
+ reply[:item] = request[:item]
78
+ reply[:value] = config.send(request[:item])
79
+ end
80
+
81
+ # Responds to PING requests with the local timestamp
82
+ action "ping" do
83
+ reply[:pong] = Time.now.to_i
84
+ end
85
+
86
+ # Returns all configured collectives
87
+ action "collective_info" do
88
+ config = Config.instance
89
+ reply[:main_collective] = config.main_collective
90
+ reply[:collectives] = config.collectives
91
+ end
92
+
93
+ action "get_data" do
94
+ if request[:query]
95
+ query = Data.ddl_transform_input(Data.ddl(request[:source]), request[:query].to_s)
96
+ else
97
+ query = nil
98
+ end
99
+
100
+ data = Data[ request[:source] ].lookup(query)
101
+
102
+ data.keys.each do |key|
103
+ reply[key] = data[key]
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,33 @@
1
+ metadata :name => "average",
2
+ :description => "Displays the average of a set of numeric values",
3
+ :author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
4
+ :license => "ASL 2.0",
5
+ :version => "1.0",
6
+ :url => "http://projects.puppetlabs.com/projects/mcollective-plugins/wiki",
7
+ :timeout => 5
8
+
9
+ usage <<-USAGE
10
+
11
+ This aggregate plugin will determine te average of a set of numeric values.
12
+
13
+ DDL Example:
14
+
15
+ summarize do
16
+ aggregate average(:value)
17
+ end
18
+
19
+ Sample Output:
20
+
21
+ host1.example.com
22
+ Value: 10
23
+
24
+ host2.example.com
25
+ Value: 20
26
+
27
+
28
+ Summary of Value:
29
+
30
+ Average of Value: 15.000000
31
+
32
+ USAGE
33
+
@@ -0,0 +1,29 @@
1
+ module MCollective
2
+ class Aggregate
3
+ class Average<Base
4
+ # Before function is run processing
5
+ def startup_hook
6
+ @result[:value] = 0
7
+ @result[:type] = :numeric
8
+
9
+ @count = 0
10
+
11
+ # Set default aggregate_function if it is undefined
12
+ @aggregate_format = "Average of #{@result[:output]}: %f" unless @aggregate_format
13
+ end
14
+
15
+ # Determines the average of a set of numerical values
16
+ def process_result(value, reply)
17
+ @result[:value] += value
18
+ @count += 1
19
+ end
20
+
21
+ # Stops execution of the function and returns a ResultObject
22
+ def summarize
23
+ @result[:value] /= @count
24
+
25
+ result_class(:numeric).new(@result, @aggregate_format, @action)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,9 +1,9 @@
1
1
  module MCollective
2
2
  class Aggregate
3
3
  module Result
4
- autoload :Base, 'mcollective/aggregate/result/base'
5
- autoload :NumericResult, 'mcollective/aggregate/result/numeric_result'
6
- autoload :CollectionResult, 'mcollective/aggregate/result/collection_result'
4
+ require 'mcollective/aggregate/result/base'
5
+ require 'mcollective/aggregate/result/numeric_result'
6
+ require 'mcollective/aggregate/result/collection_result'
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,33 @@
1
+ metadata :name => "Sum",
2
+ :description => "Determine the total added value of a set of values",
3
+ :author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
4
+ :license => "ASL 2.0",
5
+ :version => "1.0",
6
+ :url => "http://projects.puppetlabs.com/projects/mcollective-plugins/wiki",
7
+ :timeout => 5
8
+
9
+ usage <<-USAGE
10
+
11
+ This aggregate plugin will determine the total added value of a set of values.
12
+
13
+ DDL Example:
14
+
15
+ summarize do
16
+ aggregate sum(:value)
17
+ end
18
+
19
+ Sample Output:
20
+
21
+ host1.example.com
22
+ Value: 10
23
+
24
+ host2.example.com
25
+ Value: 20
26
+
27
+
28
+ Summary of Value:
29
+
30
+ Sum of Value: 30
31
+
32
+ USAGE
33
+
@@ -0,0 +1,18 @@
1
+ module MCollective
2
+ class Aggregate
3
+ class Sum<Base
4
+ def startup_hook
5
+ @result[:value] = 0
6
+ @result[:type] = :numeric
7
+
8
+ # Set default aggregate_function if it is undefined
9
+ @aggregate_format = "Sum of #{@result[:output]}: %f" unless @aggregate_format
10
+ end
11
+
12
+ # Determines the average of a set of numerical values
13
+ def process_result(value, reply)
14
+ @result[:value] += value
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ metadata :name => "summary",
2
+ :description => "Displays the summary of a set of results",
3
+ :author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
4
+ :license => "ASL 2.0",
5
+ :version => "1.0",
6
+ :url => "http://projects.puppetlabs.com/projects/mcollective-plugins/wiki",
7
+ :timeout => 5
8
+
9
+ usage <<-USAGE
10
+
11
+ This aggregate plugin will display the summary of a set of results.
12
+
13
+ DDL Example:
14
+
15
+ summarize do
16
+ aggregate summary(:value)
17
+ end
18
+
19
+ Sample Output:
20
+
21
+ host1.example.com
22
+ Property: collectives
23
+ Value: ["mcollective", "uk_collective"]
24
+
25
+ Summary of Value:
26
+
27
+ mcollective = 25
28
+ uk_collective = 15
29
+ fr_collective = 9
30
+ us_collective = 1
31
+
32
+ USAGE
33
+
@@ -0,0 +1,53 @@
1
+ module MCollective
2
+ class Aggregate
3
+ class Summary<Base
4
+ # Before function is run processing
5
+ def startup_hook
6
+ @result[:value] = {}
7
+ @result[:type] = :collection
8
+
9
+ # set default aggregate_format if it is undefined
10
+ @aggregate_format = :calculate unless @aggregate_format
11
+ end
12
+
13
+ # Increments the value field if value has been seen before
14
+ # Else create a new value field
15
+ def process_result(value, reply)
16
+ unless value.nil?
17
+ if value.is_a? Array
18
+ value.map{|val| add_value(val)}
19
+ else
20
+ add_value(value)
21
+ end
22
+ end
23
+ end
24
+
25
+ def add_value(value)
26
+ if @result[:value].keys.include?(value)
27
+ @result[:value][value] += 1
28
+ else
29
+ @result[:value][value] = 1
30
+ end
31
+ end
32
+
33
+ def summarize
34
+ if @aggregate_format == :calculate
35
+ max_key_length = @result[:value].keys.map do |k|
36
+
37
+ # Response values retain their types. Here we check
38
+ # if the response is a string and turn it into a string
39
+ # if it isn't one.
40
+ if k.respond_to?(:length)
41
+ k.length
42
+ elsif k.respond_to?(:to_s)
43
+ k.to_s.length
44
+ end
45
+ end.max
46
+ @aggregate_format = "%#{max_key_length}s = %s"
47
+ end
48
+
49
+ super
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,7 +1,7 @@
1
1
  module MCollective
2
2
  class Aggregate
3
- autoload :Result, 'mcollective/aggregate/result'
4
- autoload :Base, 'mcollective/aggregate/base'
3
+ require 'mcollective/aggregate/result'
4
+ require 'mcollective/aggregate/base'
5
5
 
6
6
  attr_accessor :ddl, :functions, :action, :failed
7
7
 
@@ -0,0 +1,104 @@
1
+ module MCollective
2
+ class Application::Completion<MCollective::Application
3
+ description "Helper for shell completion systems"
4
+
5
+ exclude_argument_sections "common", "filter", "rpc"
6
+
7
+ option :list_agents,
8
+ :description => "List all known agents",
9
+ :arguments => "--list-agents",
10
+ :required => false,
11
+ :type => :boolean
12
+
13
+ option :list_actions,
14
+ :description => "List all actions for an agent",
15
+ :arguments => "--list-actions",
16
+ :required => false,
17
+ :type => :boolean
18
+
19
+ option :list_inputs,
20
+ :description => "List all inputs for an action",
21
+ :arguments => "--list-inputs",
22
+ :required => false,
23
+ :type => :boolean
24
+
25
+ option :list_applications,
26
+ :description => "List all known applications",
27
+ :arguments => "--list-applications",
28
+ :required => false,
29
+ :type => :boolean
30
+
31
+ option :agent,
32
+ :description => "The agent to operate on",
33
+ :arguments => "--agent AGENT",
34
+ :required => false
35
+
36
+ option :action,
37
+ :description => "The action to operate on",
38
+ :arguments => "--action ACTION",
39
+ :required => false
40
+
41
+ def list_agents
42
+ if options[:verbose]
43
+ PluginManager.find(:agent, "ddl").each do |agent|
44
+ begin
45
+ ddl = DDL.new(agent)
46
+ puts "%s:%s" % [ agent, ddl.meta[:description] ]
47
+ rescue
48
+ end
49
+ end
50
+ else
51
+ PluginManager.find(:agent, "ddl").each {|p| puts p}
52
+ end
53
+ end
54
+
55
+ def list_actions
56
+ abort "Please specify an agent to list actions for" unless configuration[:agent]
57
+
58
+ if options[:verbose]
59
+ ddl = DDL.new(configuration[:agent], :agent)
60
+
61
+ ddl.actions.sort.each do |action|
62
+ puts "%s:%s" % [action, ddl.action_interface(action)[:description]]
63
+ end
64
+ else
65
+ DDL.new(configuration[:agent], :agent).actions.sort.each {|a| puts a}
66
+ end
67
+ rescue
68
+ end
69
+
70
+ def list_inputs
71
+ abort "Please specify an action and agent to list inputs for" unless configuration[:agent] && configuration[:action]
72
+
73
+ if options[:verbose]
74
+ ddl = DDL.new(configuration[:agent], :agent)
75
+ action = ddl.action_interface(configuration[:action])
76
+ action[:input].keys.sort.each do |input|
77
+ puts "%s:%s" % [input, action[:input][input][:description]]
78
+ end
79
+ else
80
+ DDL.new(configuration[:agent], :agent).action_interface(configuration[:action])[:input].keys.sort.each {|i| puts i}
81
+ end
82
+ rescue
83
+ end
84
+
85
+ def list_applications
86
+ if options[:verbose]
87
+ Applications.list.each do |app|
88
+ puts "%s:%s" % [app, Applications[app].application_description]
89
+ end
90
+ else
91
+ Applications.list.each {|a| puts a}
92
+ end
93
+ end
94
+
95
+ def main
96
+ actions = configuration.keys.map{|k| k.to_s}.grep(/^list_/)
97
+
98
+ abort "Please choose either --list-[agents|actions|inputs|applications]" if actions.empty?
99
+ abort "Please choose only one of --list-[agents|actions|inputs|applications]" if actions.size > 1
100
+
101
+ send actions.first
102
+ end
103
+ end
104
+ end