mcollective-client 2.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mcollective-client might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/lib/mcollective.rb +32 -23
  2. data/lib/mcollective/agent.rb +5 -0
  3. data/lib/mcollective/agents.rb +5 -16
  4. data/lib/mcollective/aggregate.rb +61 -0
  5. data/lib/mcollective/aggregate/base.rb +40 -0
  6. data/lib/mcollective/aggregate/result.rb +9 -0
  7. data/lib/mcollective/aggregate/result/base.rb +25 -0
  8. data/lib/mcollective/aggregate/result/collection_result.rb +19 -0
  9. data/lib/mcollective/aggregate/result/numeric_result.rb +13 -0
  10. data/lib/mcollective/application.rb +7 -4
  11. data/lib/mcollective/applications.rb +3 -14
  12. data/lib/mcollective/cache.rb +145 -0
  13. data/lib/mcollective/client.rb +10 -87
  14. data/lib/mcollective/config.rb +22 -8
  15. data/lib/mcollective/data.rb +87 -0
  16. data/lib/mcollective/data/base.rb +67 -0
  17. data/lib/mcollective/data/result.rb +40 -0
  18. data/lib/mcollective/ddl.rb +113 -0
  19. data/lib/mcollective/ddl/agentddl.rb +185 -0
  20. data/lib/mcollective/ddl/base.rb +220 -0
  21. data/lib/mcollective/ddl/dataddl.rb +56 -0
  22. data/lib/mcollective/ddl/discoveryddl.rb +52 -0
  23. data/lib/mcollective/ddl/validatorddl.rb +6 -0
  24. data/lib/mcollective/discovery.rb +143 -0
  25. data/lib/mcollective/generators.rb +7 -0
  26. data/lib/mcollective/generators/agent_generator.rb +51 -0
  27. data/lib/mcollective/generators/base.rb +46 -0
  28. data/lib/mcollective/generators/data_generator.rb +51 -0
  29. data/lib/mcollective/generators/templates/action_snippet.erb +13 -0
  30. data/lib/mcollective/generators/templates/data_input_snippet.erb +7 -0
  31. data/lib/mcollective/generators/templates/ddl.erb +8 -0
  32. data/lib/mcollective/generators/templates/plugin.erb +7 -0
  33. data/lib/mcollective/logger/console_logger.rb +15 -15
  34. data/lib/mcollective/matcher.rb +167 -0
  35. data/lib/mcollective/matcher/parser.rb +60 -25
  36. data/lib/mcollective/matcher/scanner.rb +156 -78
  37. data/lib/mcollective/message.rb +47 -6
  38. data/lib/mcollective/monkey_patches.rb +17 -0
  39. data/lib/mcollective/optionparser.rb +18 -1
  40. data/lib/mcollective/pluginmanager.rb +3 -3
  41. data/lib/mcollective/pluginpackager.rb +10 -3
  42. data/lib/mcollective/pluginpackager/agent_definition.rb +28 -20
  43. data/lib/mcollective/pluginpackager/standard_definition.rb +11 -9
  44. data/lib/mcollective/registration/base.rb +3 -1
  45. data/lib/mcollective/rpc.rb +18 -24
  46. data/lib/mcollective/rpc/agent.rb +37 -113
  47. data/lib/mcollective/rpc/client.rb +186 -64
  48. data/lib/mcollective/rpc/helpers.rb +42 -80
  49. data/lib/mcollective/rpc/progress.rb +3 -3
  50. data/lib/mcollective/rpc/reply.rb +37 -13
  51. data/lib/mcollective/rpc/request.rb +17 -6
  52. data/lib/mcollective/rpc/result.rb +9 -5
  53. data/lib/mcollective/rpc/stats.rb +71 -24
  54. data/lib/mcollective/security/base.rb +41 -34
  55. data/lib/mcollective/shell.rb +1 -1
  56. data/lib/mcollective/ssl.rb +34 -0
  57. data/lib/mcollective/util.rb +194 -23
  58. data/lib/mcollective/validator.rb +80 -0
  59. data/spec/fixtures/util/1.in +10 -0
  60. data/spec/fixtures/util/1.out +10 -0
  61. data/spec/fixtures/util/2.in +1 -0
  62. data/spec/fixtures/util/2.out +1 -0
  63. data/spec/fixtures/util/3.in +1 -0
  64. data/spec/fixtures/util/3.out +2 -0
  65. data/spec/fixtures/util/4.in +5 -0
  66. data/spec/fixtures/util/4.out +9 -0
  67. data/spec/spec.opts +1 -1
  68. data/spec/spec_helper.rb +2 -0
  69. data/spec/unit/agents_spec.rb +34 -19
  70. data/spec/unit/aggregate/base_spec.rb +57 -0
  71. data/spec/unit/aggregate/result/base_spec.rb +28 -0
  72. data/spec/unit/aggregate/result/collection_result_spec.rb +18 -0
  73. data/spec/unit/aggregate/result/numeric_result_spec.rb +22 -0
  74. data/spec/unit/aggregate_spec.rb +110 -0
  75. data/spec/unit/application_spec.rb +8 -3
  76. data/spec/unit/applications_spec.rb +2 -2
  77. data/spec/unit/cache_spec.rb +115 -0
  78. data/spec/unit/client_spec.rb +78 -0
  79. data/spec/unit/config_spec.rb +32 -34
  80. data/spec/unit/data/base_spec.rb +90 -0
  81. data/spec/unit/data/result_spec.rb +64 -0
  82. data/spec/unit/data_spec.rb +158 -0
  83. data/spec/unit/ddl/agentddl_spec.rb +217 -0
  84. data/spec/unit/{rpc/ddl_spec.rb → ddl/base_spec.rb} +238 -224
  85. data/spec/unit/ddl/dataddl_spec.rb +65 -0
  86. data/spec/unit/ddl/discoveryddl_spec.rb +58 -0
  87. data/spec/unit/ddl_spec.rb +84 -0
  88. data/spec/unit/discovery_spec.rb +196 -0
  89. data/spec/unit/facts/base_spec.rb +1 -1
  90. data/spec/unit/generators/agent_generator_spec.rb +72 -0
  91. data/spec/unit/generators/base_spec.rb +83 -0
  92. data/spec/unit/generators/data_generator_spec.rb +37 -0
  93. data/spec/unit/generators/snippets/agent_ddl +19 -0
  94. data/spec/unit/generators/snippets/data_ddl +20 -0
  95. data/spec/unit/logger/console_logger_spec.rb +76 -0
  96. data/spec/unit/logger/syslog_logger_spec.rb +2 -2
  97. data/spec/unit/matcher/parser_spec.rb +27 -10
  98. data/spec/unit/matcher/scanner_spec.rb +108 -5
  99. data/spec/unit/matcher_spec.rb +260 -0
  100. data/spec/unit/message_spec.rb +35 -13
  101. data/spec/unit/optionparser_spec.rb +2 -2
  102. data/spec/unit/pluginpackager/agent_definition_spec.rb +59 -42
  103. data/spec/unit/pluginpackager/standard_definition_spec.rb +10 -8
  104. data/spec/unit/pluginpackager_spec.rb +131 -0
  105. data/spec/unit/plugins/mcollective/aggregate/average_spec.rb +45 -0
  106. data/spec/unit/plugins/mcollective/aggregate/sum_spec.rb +31 -0
  107. data/spec/unit/plugins/mcollective/aggregate/summary_spec.rb +45 -0
  108. data/spec/unit/plugins/mcollective/connector/activemq_spec.rb +1 -1
  109. data/spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb +478 -0
  110. data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +2 -0
  111. data/spec/unit/plugins/mcollective/data/agent_data_spec.rb +43 -0
  112. data/spec/unit/plugins/mcollective/data/fstat_data_spec.rb +135 -0
  113. data/spec/unit/plugins/mcollective/discovery/flatfile_spec.rb +48 -0
  114. data/spec/unit/plugins/mcollective/discovery/mc_spec.rb +40 -0
  115. data/spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb +41 -15
  116. data/spec/unit/plugins/mcollective/packagers/ospackage_spec.rb +1 -1
  117. data/spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb +22 -38
  118. data/spec/unit/plugins/mcollective/validator/array_validator_spec.rb +19 -0
  119. data/spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb +19 -0
  120. data/spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb +19 -0
  121. data/spec/unit/plugins/mcollective/validator/length_validator_spec.rb +19 -0
  122. data/spec/unit/plugins/mcollective/validator/regex_validator_spec.rb +19 -0
  123. data/spec/unit/plugins/mcollective/validator/shellsafe_validator_spec.rb +21 -0
  124. data/spec/unit/plugins/mcollective/validator/typecheck_validator_spec.rb +23 -0
  125. data/spec/unit/registration/base_spec.rb +1 -1
  126. data/spec/unit/rpc/actionrunner_spec.rb +2 -2
  127. data/spec/unit/rpc/agent_spec.rb +41 -65
  128. data/spec/unit/rpc/client_spec.rb +430 -134
  129. data/spec/unit/rpc/reply_spec.rb +31 -1
  130. data/spec/unit/rpc/request_spec.rb +33 -12
  131. data/spec/unit/rpc/result_spec.rb +7 -0
  132. data/spec/unit/rpc/stats_spec.rb +14 -14
  133. data/spec/unit/rpc_spec.rb +16 -0
  134. data/spec/unit/security/base_spec.rb +8 -8
  135. data/spec/unit/ssl_spec.rb +20 -2
  136. data/spec/unit/string_spec.rb +15 -0
  137. data/spec/unit/util_spec.rb +141 -21
  138. data/spec/unit/validator_spec.rb +67 -0
  139. metadata +145 -7
  140. data/lib/mcollective/rpc/ddl.rb +0 -258
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+ require File.dirname(__FILE__) + '/../../plugins/mcollective/validator/array_validator.rb'
5
+
6
+ module MCollective
7
+ module Validator
8
+ describe "#load_validators" do
9
+ it "should not reload the plugins if the plugin cache has not expired" do
10
+ Validator.instance_variable_set(:@last_load, nil)
11
+ PluginManager.expects(:find_and_load).with("validator").once
12
+ Validator.load_validators
13
+ Validator.load_validators
14
+ end
15
+ end
16
+
17
+ describe "#[]" do
18
+ before do
19
+ Validator.load_validators
20
+ end
21
+
22
+ it "should return the correct class if klass is given as klass" do
23
+ result = Validator["array"]
24
+ result.should == ArrayValidator
25
+ end
26
+ it "should return the correct class if klass is given as KlassValidator" do
27
+ result = Validator["ArrayValidator"]
28
+ result.should == ArrayValidator
29
+ end
30
+ it "should return the correct class if klass is given as :klass" do
31
+ result = Validator[:array]
32
+ result.should == ArrayValidator
33
+ end
34
+ end
35
+
36
+ describe "#method_missing" do
37
+ it "should load a plugin if a validator method is called and the plugin exists" do
38
+ ArrayValidator.expects(:validate).with(2, [1,2,3])
39
+ result = Validator.array(2,[1,2,3])
40
+ end
41
+
42
+ it "should call super if a validator method is called and the plugin does not exist" do
43
+ expect{
44
+ Validator.test(1,2,3)
45
+ }.to raise_error(ValidatorError)
46
+ end
47
+ end
48
+
49
+ describe "#validator_class" do
50
+ it "should return the correct string for a given validator plugin name" do
51
+ result = Validator.validator_class("test")
52
+ result.should == "TestValidator"
53
+ end
54
+ end
55
+
56
+ describe "#has_validator?" do
57
+ it "should return true if the validator has been loaded" do
58
+ Validator.const_set(:TestValidator, Class)
59
+ Validator.has_validator?("test").should == true
60
+ end
61
+
62
+ it "should return false if the validator has not been loaded" do
63
+ Validator.has_validator?("test2").should == false
64
+ end
65
+ end
66
+ end
67
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcollective-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 2
8
9
  - 0
9
- - 0
10
- version: 2.0.0
10
+ version: 2.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-30 00:00:00 Z
18
+ date: 2012-09-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: systemu
@@ -45,6 +45,20 @@ dependencies:
45
45
  version: "0"
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: stomp
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
48
62
  description: Client libraries for the mcollective Application Server
49
63
  email: rip@puppetlabs.com
50
64
  executables:
@@ -56,11 +70,18 @@ extra_rdoc_files: []
56
70
  files:
57
71
  - bin/mc-call-agent
58
72
  - bin/mco
73
+ - lib/mcollective/data.rb
59
74
  - lib/mcollective/connector/base.rb
60
75
  - lib/mcollective/windows_daemon.rb
61
76
  - lib/mcollective/vendor/require_vendored.rb
62
77
  - lib/mcollective/shell.rb
63
78
  - lib/mcollective/ssl.rb
79
+ - lib/mcollective/aggregate/base.rb
80
+ - lib/mcollective/aggregate/result/numeric_result.rb
81
+ - lib/mcollective/aggregate/result/base.rb
82
+ - lib/mcollective/aggregate/result/collection_result.rb
83
+ - lib/mcollective/aggregate/result.rb
84
+ - lib/mcollective/agent.rb
64
85
  - lib/mcollective/facts/base.rb
65
86
  - lib/mcollective/application.rb
66
87
  - lib/mcollective/message.rb
@@ -70,7 +91,6 @@ files:
70
91
  - lib/mcollective/rpc/request.rb
71
92
  - lib/mcollective/rpc/reply.rb
72
93
  - lib/mcollective/rpc/progress.rb
73
- - lib/mcollective/rpc/ddl.rb
74
94
  - lib/mcollective/rpc/result.rb
75
95
  - lib/mcollective/rpc/helpers.rb
76
96
  - lib/mcollective/rpc/actionrunner.rb
@@ -82,14 +102,29 @@ files:
82
102
  - lib/mcollective/runnerstats.rb
83
103
  - lib/mcollective/pluginpackager/agent_definition.rb
84
104
  - lib/mcollective/pluginpackager/standard_definition.rb
105
+ - lib/mcollective/discovery.rb
85
106
  - lib/mcollective/vendor.rb
86
107
  - lib/mcollective/facts.rb
87
108
  - lib/mcollective/logger.rb
109
+ - lib/mcollective/generators.rb
110
+ - lib/mcollective/ddl/base.rb
111
+ - lib/mcollective/ddl/agentddl.rb
112
+ - lib/mcollective/ddl/discoveryddl.rb
113
+ - lib/mcollective/ddl/dataddl.rb
114
+ - lib/mcollective/ddl/validatorddl.rb
88
115
  - lib/mcollective/logger/file_logger.rb
89
116
  - lib/mcollective/logger/console_logger.rb
90
117
  - lib/mcollective/logger/base.rb
91
118
  - lib/mcollective/logger/syslog_logger.rb
119
+ - lib/mcollective/generators/base.rb
120
+ - lib/mcollective/generators/templates/data_input_snippet.erb
121
+ - lib/mcollective/generators/templates/ddl.erb
122
+ - lib/mcollective/generators/templates/action_snippet.erb
123
+ - lib/mcollective/generators/templates/plugin.erb
124
+ - lib/mcollective/generators/data_generator.rb
125
+ - lib/mcollective/generators/agent_generator.rb
92
126
  - lib/mcollective/config.rb
127
+ - lib/mcollective/ddl.rb
93
128
  - lib/mcollective/connector.rb
94
129
  - lib/mcollective/registration/base.rb
95
130
  - lib/mcollective/registration.rb
@@ -98,8 +133,13 @@ files:
98
133
  - lib/mcollective/security/base.rb
99
134
  - lib/mcollective/matcher.rb
100
135
  - lib/mcollective/unix_daemon.rb
136
+ - lib/mcollective/data/base.rb
137
+ - lib/mcollective/data/result.rb
138
+ - lib/mcollective/validator.rb
139
+ - lib/mcollective/aggregate.rb
101
140
  - lib/mcollective/rpc.rb
102
141
  - lib/mcollective/optionparser.rb
142
+ - lib/mcollective/cache.rb
103
143
  - lib/mcollective/matcher/parser.rb
104
144
  - lib/mcollective/matcher/scanner.rb
105
145
  - lib/mcollective/client.rb
@@ -111,12 +151,26 @@ files:
111
151
  - spec/fixtures/application/test.rb
112
152
  - spec/fixtures/test-private.pem
113
153
  - spec/fixtures/test-cert.pem
154
+ - spec/fixtures/util/1.in
155
+ - spec/fixtures/util/4.in
156
+ - spec/fixtures/util/1.out
157
+ - spec/fixtures/util/3.in
158
+ - spec/fixtures/util/2.in
159
+ - spec/fixtures/util/2.out
160
+ - spec/fixtures/util/4.out
161
+ - spec/fixtures/util/3.out
162
+ - spec/unit/data_spec.rb
114
163
  - spec/unit/application_spec.rb
164
+ - spec/unit/ddl_spec.rb
165
+ - spec/unit/aggregate/base_spec.rb
166
+ - spec/unit/aggregate/result/base_spec.rb
167
+ - spec/unit/aggregate/result/numeric_result_spec.rb
168
+ - spec/unit/aggregate/result/collection_result_spec.rb
169
+ - spec/unit/client_spec.rb
115
170
  - spec/unit/unix_daemon_spec.rb
116
171
  - spec/unit/facts/base_spec.rb
117
172
  - spec/unit/array_spec.rb
118
173
  - spec/unit/rpc/reply_spec.rb
119
- - spec/unit/rpc/ddl_spec.rb
120
174
  - spec/unit/rpc/client_spec.rb
121
175
  - spec/unit/rpc/helpers_spec.rb
122
176
  - spec/unit/rpc/request_spec.rb
@@ -125,31 +179,66 @@ files:
125
179
  - spec/unit/rpc/actionrunner_spec.rb
126
180
  - spec/unit/rpc/stats_spec.rb
127
181
  - spec/unit/windows_daemon_spec.rb
182
+ - spec/unit/cache_spec.rb
128
183
  - spec/unit/optionparser_spec.rb
184
+ - spec/unit/string_spec.rb
129
185
  - spec/unit/pluginpackager/agent_definition_spec.rb
130
186
  - spec/unit/pluginpackager/standard_definition_spec.rb
131
187
  - spec/unit/ssl_spec.rb
132
188
  - spec/unit/config_spec.rb
133
189
  - spec/unit/applications_spec.rb
190
+ - spec/unit/validator_spec.rb
134
191
  - spec/unit/runnerstats_spec.rb
192
+ - spec/unit/ddl/base_spec.rb
193
+ - spec/unit/ddl/dataddl_spec.rb
194
+ - spec/unit/ddl/agentddl_spec.rb
195
+ - spec/unit/ddl/discoveryddl_spec.rb
196
+ - spec/unit/logger/console_logger_spec.rb
135
197
  - spec/unit/logger/base_spec.rb
136
198
  - spec/unit/logger/syslog_logger_spec.rb
199
+ - spec/unit/generators/agent_generator_spec.rb
200
+ - spec/unit/generators/snippets/agent_ddl
201
+ - spec/unit/generators/snippets/data_ddl
202
+ - spec/unit/generators/base_spec.rb
203
+ - spec/unit/generators/data_generator_spec.rb
204
+ - spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb
137
205
  - spec/unit/plugins/mcollective/connector/activemq_spec.rb
138
206
  - spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
139
207
  - spec/unit/plugins/mcollective/connector/stomp_spec.rb
208
+ - spec/unit/plugins/mcollective/aggregate/sum_spec.rb
209
+ - spec/unit/plugins/mcollective/aggregate/average_spec.rb
210
+ - spec/unit/plugins/mcollective/aggregate/summary_spec.rb
211
+ - spec/unit/plugins/mcollective/discovery/flatfile_spec.rb
212
+ - spec/unit/plugins/mcollective/discovery/mc_spec.rb
140
213
  - spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
141
214
  - spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
142
215
  - spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
143
216
  - spec/unit/plugins/mcollective/security/psk_spec.rb
217
+ - spec/unit/plugins/mcollective/data/fstat_data_spec.rb
218
+ - spec/unit/plugins/mcollective/data/agent_data_spec.rb
219
+ - spec/unit/plugins/mcollective/validator/regex_validator_spec.rb
220
+ - spec/unit/plugins/mcollective/validator/shellsafe_validator_spec.rb
221
+ - spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb
222
+ - spec/unit/plugins/mcollective/validator/typecheck_validator_spec.rb
223
+ - spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb
224
+ - spec/unit/plugins/mcollective/validator/array_validator_spec.rb
225
+ - spec/unit/plugins/mcollective/validator/length_validator_spec.rb
226
+ - spec/unit/pluginpackager_spec.rb
144
227
  - spec/unit/registration/base_spec.rb
145
228
  - spec/unit/agents_spec.rb
146
229
  - spec/unit/security/base_spec.rb
147
230
  - spec/unit/vendor_spec.rb
148
231
  - spec/unit/message_spec.rb
232
+ - spec/unit/rpc_spec.rb
233
+ - spec/unit/data/base_spec.rb
234
+ - spec/unit/data/result_spec.rb
235
+ - spec/unit/matcher_spec.rb
149
236
  - spec/unit/log_spec.rb
237
+ - spec/unit/aggregate_spec.rb
150
238
  - spec/unit/facts_spec.rb
151
239
  - spec/unit/shell_spec.rb
152
240
  - spec/unit/pluginmanager_spec.rb
241
+ - spec/unit/discovery_spec.rb
153
242
  - spec/unit/matcher/parser_spec.rb
154
243
  - spec/unit/matcher/scanner_spec.rb
155
244
  - spec/unit/symbol_spec.rb
@@ -197,12 +286,26 @@ test_files:
197
286
  - spec/fixtures/application/test.rb
198
287
  - spec/fixtures/test-private.pem
199
288
  - spec/fixtures/test-cert.pem
289
+ - spec/fixtures/util/1.in
290
+ - spec/fixtures/util/4.in
291
+ - spec/fixtures/util/1.out
292
+ - spec/fixtures/util/3.in
293
+ - spec/fixtures/util/2.in
294
+ - spec/fixtures/util/2.out
295
+ - spec/fixtures/util/4.out
296
+ - spec/fixtures/util/3.out
297
+ - spec/unit/data_spec.rb
200
298
  - spec/unit/application_spec.rb
299
+ - spec/unit/ddl_spec.rb
300
+ - spec/unit/aggregate/base_spec.rb
301
+ - spec/unit/aggregate/result/base_spec.rb
302
+ - spec/unit/aggregate/result/numeric_result_spec.rb
303
+ - spec/unit/aggregate/result/collection_result_spec.rb
304
+ - spec/unit/client_spec.rb
201
305
  - spec/unit/unix_daemon_spec.rb
202
306
  - spec/unit/facts/base_spec.rb
203
307
  - spec/unit/array_spec.rb
204
308
  - spec/unit/rpc/reply_spec.rb
205
- - spec/unit/rpc/ddl_spec.rb
206
309
  - spec/unit/rpc/client_spec.rb
207
310
  - spec/unit/rpc/helpers_spec.rb
208
311
  - spec/unit/rpc/request_spec.rb
@@ -211,31 +314,66 @@ test_files:
211
314
  - spec/unit/rpc/actionrunner_spec.rb
212
315
  - spec/unit/rpc/stats_spec.rb
213
316
  - spec/unit/windows_daemon_spec.rb
317
+ - spec/unit/cache_spec.rb
214
318
  - spec/unit/optionparser_spec.rb
319
+ - spec/unit/string_spec.rb
215
320
  - spec/unit/pluginpackager/agent_definition_spec.rb
216
321
  - spec/unit/pluginpackager/standard_definition_spec.rb
217
322
  - spec/unit/ssl_spec.rb
218
323
  - spec/unit/config_spec.rb
219
324
  - spec/unit/applications_spec.rb
325
+ - spec/unit/validator_spec.rb
220
326
  - spec/unit/runnerstats_spec.rb
327
+ - spec/unit/ddl/base_spec.rb
328
+ - spec/unit/ddl/dataddl_spec.rb
329
+ - spec/unit/ddl/agentddl_spec.rb
330
+ - spec/unit/ddl/discoveryddl_spec.rb
331
+ - spec/unit/logger/console_logger_spec.rb
221
332
  - spec/unit/logger/base_spec.rb
222
333
  - spec/unit/logger/syslog_logger_spec.rb
334
+ - spec/unit/generators/agent_generator_spec.rb
335
+ - spec/unit/generators/snippets/agent_ddl
336
+ - spec/unit/generators/snippets/data_ddl
337
+ - spec/unit/generators/base_spec.rb
338
+ - spec/unit/generators/data_generator_spec.rb
339
+ - spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb
223
340
  - spec/unit/plugins/mcollective/connector/activemq_spec.rb
224
341
  - spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
225
342
  - spec/unit/plugins/mcollective/connector/stomp_spec.rb
343
+ - spec/unit/plugins/mcollective/aggregate/sum_spec.rb
344
+ - spec/unit/plugins/mcollective/aggregate/average_spec.rb
345
+ - spec/unit/plugins/mcollective/aggregate/summary_spec.rb
346
+ - spec/unit/plugins/mcollective/discovery/flatfile_spec.rb
347
+ - spec/unit/plugins/mcollective/discovery/mc_spec.rb
226
348
  - spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
227
349
  - spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
228
350
  - spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
229
351
  - spec/unit/plugins/mcollective/security/psk_spec.rb
352
+ - spec/unit/plugins/mcollective/data/fstat_data_spec.rb
353
+ - spec/unit/plugins/mcollective/data/agent_data_spec.rb
354
+ - spec/unit/plugins/mcollective/validator/regex_validator_spec.rb
355
+ - spec/unit/plugins/mcollective/validator/shellsafe_validator_spec.rb
356
+ - spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb
357
+ - spec/unit/plugins/mcollective/validator/typecheck_validator_spec.rb
358
+ - spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb
359
+ - spec/unit/plugins/mcollective/validator/array_validator_spec.rb
360
+ - spec/unit/plugins/mcollective/validator/length_validator_spec.rb
361
+ - spec/unit/pluginpackager_spec.rb
230
362
  - spec/unit/registration/base_spec.rb
231
363
  - spec/unit/agents_spec.rb
232
364
  - spec/unit/security/base_spec.rb
233
365
  - spec/unit/vendor_spec.rb
234
366
  - spec/unit/message_spec.rb
367
+ - spec/unit/rpc_spec.rb
368
+ - spec/unit/data/base_spec.rb
369
+ - spec/unit/data/result_spec.rb
370
+ - spec/unit/matcher_spec.rb
235
371
  - spec/unit/log_spec.rb
372
+ - spec/unit/aggregate_spec.rb
236
373
  - spec/unit/facts_spec.rb
237
374
  - spec/unit/shell_spec.rb
238
375
  - spec/unit/pluginmanager_spec.rb
376
+ - spec/unit/discovery_spec.rb
239
377
  - spec/unit/matcher/parser_spec.rb
240
378
  - spec/unit/matcher/scanner_spec.rb
241
379
  - spec/unit/symbol_spec.rb
@@ -1,258 +0,0 @@
1
- module MCollective
2
- module RPC
3
- # A class that helps creating data description language files
4
- # for agents. You can define meta data, actions, input and output
5
- # describing the behavior of your agent.
6
- #
7
- # Later you can access this information to assist with creating
8
- # of user interfaces or online help
9
- #
10
- # A sample DDL can be seen below, you'd put this in your agent
11
- # dir as <agent name>.ddl
12
- #
13
- # metadata :name => "SimpleRPC Service Agent",
14
- # :description => "Agent to manage services using the Puppet service provider",
15
- # :author => "R.I.Pienaar",
16
- # :license => "GPLv2",
17
- # :version => "1.1",
18
- # :url => "http://mcollective-plugins.googlecode.com/",
19
- # :timeout => 60
20
- #
21
- # action "status", :description => "Gets the status of a service" do
22
- # display :always
23
- #
24
- # input "service",
25
- # :prompt => "Service Name",
26
- # :description => "The service to get the status for",
27
- # :type => :string,
28
- # :validation => '^[a-zA-Z\-_\d]+$',
29
- # :optional => true,
30
- # :maxlength => 30
31
- #
32
- # output "status",
33
- # :description => "The status of service",
34
- # :display_as => "Service Status"
35
- # end
36
- class DDL
37
- attr_reader :meta
38
-
39
- def initialize(agent, loadddl=true)
40
- @actions = {}
41
- @meta = {}
42
- @config = MCollective::Config.instance
43
- @agent = agent
44
-
45
- if loadddl
46
- if ddlfile = findddlfile(agent)
47
- instance_eval(File.read(ddlfile))
48
- else
49
- raise("Can't find DDL for agent '#{agent}'")
50
- end
51
- end
52
- end
53
-
54
- def findddlfile(agent)
55
- @config.libdir.each do |libdir|
56
- ddlfile = File.join([libdir, "mcollective", "agent", "#{agent}.ddl"])
57
-
58
- if File.exist?(ddlfile)
59
- Log.debug("Found #{agent} ddl at #{ddlfile}")
60
- return ddlfile
61
- end
62
- end
63
- return false
64
- end
65
-
66
- # Registers meta data for the introspection hash
67
- def metadata(meta)
68
- [:name, :description, :author, :license, :version, :url, :timeout].each do |arg|
69
- raise "Metadata needs a :#{arg}" unless meta.include?(arg)
70
- end
71
-
72
- @meta = meta
73
- end
74
-
75
- # Creates the definition for an action, you can nest input definitions inside the
76
- # action to attach inputs and validation to the actions
77
- #
78
- # action "status", :description => "Restarts a Service" do
79
- # display :always
80
- #
81
- # input "service",
82
- # :prompt => "Service Action",
83
- # :description => "The action to perform",
84
- # :type => :list,
85
- # :optional => true,
86
- # :list => ["start", "stop", "restart", "status"]
87
- #
88
- # output "status"
89
- # :description => "The status of the service after the action"
90
- #
91
- # end
92
- def action(name, input, &block)
93
- raise "Action needs a :description" unless input.include?(:description)
94
-
95
- unless @actions.include?(name)
96
- @actions[name] = {}
97
- @actions[name][:action] = name
98
- @actions[name][:input] = {}
99
- @actions[name][:output] = {}
100
- @actions[name][:display] = :failed
101
- @actions[name][:description] = input[:description]
102
- end
103
-
104
- # if a block is passed it might be creating input methods, call it
105
- # we set @current_action so the input block can know what its talking
106
- # to, this is probably an epic hack, need to improve.
107
- @current_action = name
108
- block.call if block_given?
109
- @current_action = nil
110
- end
111
-
112
- # Registers an input argument for a given action
113
- #
114
- # See the documentation for action for how to use this
115
- def input(argument, properties)
116
- raise "Cannot figure out what action input #{argument} belongs to" unless @current_action
117
-
118
- action = @current_action
119
-
120
- [:prompt, :description, :type, :optional].each do |arg|
121
- raise "Input needs a :#{arg}" unless properties.include?(arg)
122
- end
123
-
124
- @actions[action][:input][argument] = {:prompt => properties[:prompt],
125
- :description => properties[:description],
126
- :type => properties[:type],
127
- :optional => properties[:optional]}
128
-
129
- case properties[:type]
130
- when :string
131
- raise "Input type :string needs a :validation argument" unless properties.include?(:validation)
132
- raise "Input type :string needs a :maxlength argument" unless properties.include?(:maxlength)
133
-
134
- @actions[action][:input][argument][:validation] = properties[:validation]
135
- @actions[action][:input][argument][:maxlength] = properties[:maxlength]
136
-
137
- when :list
138
- raise "Input type :list needs a :list argument" unless properties.include?(:list)
139
-
140
- @actions[action][:input][argument][:list] = properties[:list]
141
- end
142
- end
143
-
144
- # Registers an output argument for a given action
145
- #
146
- # See the documentation for action for how to use this
147
- def output(argument, properties)
148
- raise "Cannot figure out what action input #{argument} belongs to" unless @current_action
149
- raise "Output #{argument} needs a description argument" unless properties.include?(:description)
150
- raise "Output #{argument} needs a display_as argument" unless properties.include?(:display_as)
151
-
152
- action = @current_action
153
-
154
- @actions[action][:output][argument] = {:description => properties[:description],
155
- :display_as => properties[:display_as]}
156
- end
157
-
158
- # Sets the display preference to either :ok, :failed, :flatten or :always
159
- # operates on action level
160
- def display(pref)
161
- # defaults to old behavior, complain if its supplied and invalid
162
- unless [:ok, :failed, :flatten, :always].include?(pref)
163
- raise "Display preference #{pref} is not valid, should be :ok, :failed, :flatten or :always"
164
- end
165
-
166
- action = @current_action
167
- @actions[action][:display] = pref
168
- end
169
-
170
- # Generates help using the template based on the data
171
- # created with metadata and input
172
- def help(template)
173
- template = IO.read(template)
174
- meta = @meta
175
- actions = @actions
176
-
177
- erb = ERB.new(template, 0, '%')
178
- erb.result(binding)
179
- end
180
-
181
- # Returns an array of actions this agent support
182
- def actions
183
- @actions.keys
184
- end
185
-
186
- # Returns the interface for a specific action
187
- def action_interface(name)
188
- @actions[name] || {}
189
- end
190
-
191
- # Helper to use the DDL to figure out if the remote call should be
192
- # allowed based on action name and inputs.
193
- def validate_request(action, arguments)
194
- # is the action known?
195
- unless actions.include?(action)
196
- raise DDLValidationError, "Attempted to call action #{action} for #{@agent} but it's not declared in the DDL"
197
- end
198
-
199
- input = action_interface(action)[:input]
200
-
201
- input.keys.each do |key|
202
- unless input[key][:optional]
203
- unless arguments.keys.include?(key)
204
- raise DDLValidationError, "Action #{action} needs a #{key} argument"
205
- end
206
- end
207
-
208
- # validate strings, lists and booleans, we'll add more types of validators when
209
- # all the use cases are clear
210
- #
211
- # only does validation for arguments actually given, since some might
212
- # be optional. We validate the presense of the argument earlier so
213
- # this is a safe assumption, just to skip them.
214
- #
215
- # :string can have maxlength and regex. A maxlength of 0 will bypasss checks
216
- # :list has a array of valid values
217
- if arguments.keys.include?(key)
218
- case input[key][:type]
219
- when :string
220
- raise DDLValidationError, "Input #{key} should be a string" unless arguments[key].is_a?(String)
221
-
222
- if input[key][:maxlength].to_i > 0
223
- if arguments[key].size > input[key][:maxlength].to_i
224
- raise DDLValidationError, "Input #{key} is longer than #{input[key][:maxlength]} character(s)"
225
- end
226
- end
227
-
228
- unless arguments[key].match(Regexp.new(input[key][:validation]))
229
- raise DDLValidationError, "Input #{key} does not match validation regex #{input[key][:validation]}"
230
- end
231
-
232
- when :list
233
- unless input[key][:list].include?(arguments[key])
234
- raise DDLValidationError, "Input #{key} doesn't match list #{input[key][:list].join(', ')}"
235
- end
236
-
237
- when :boolean
238
- unless [TrueClass, FalseClass].include?(arguments[key].class)
239
- raise DDLValidationError, "Input #{key} should be a boolean"
240
- end
241
-
242
- when :integer
243
- raise DDLValidationError, "Input #{key} should be a integer" unless arguments[key].is_a?(Fixnum)
244
-
245
- when :float
246
- raise DDLValidationError, "Input #{key} should be a floating point number" unless arguments[key].is_a?(Float)
247
-
248
- when :number
249
- raise DDLValidationError, "Input #{key} should be a number" unless arguments[key].is_a?(Numeric)
250
- end
251
- end
252
- end
253
-
254
- true
255
- end
256
- end
257
- end
258
- end