mcollective-client 2.8.6 → 2.8.7
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.
- data/lib/mcollective.rb +1 -1
- data/lib/mcollective/agent/discovery.rb +1 -1
- data/lib/mcollective/agent/rpcutil.ddl +1 -1
- data/lib/mcollective/aggregate/average.ddl +1 -1
- data/lib/mcollective/aggregate/sum.ddl +1 -1
- data/lib/mcollective/aggregate/summary.ddl +1 -1
- data/lib/mcollective/connector/activemq.ddl +1 -1
- data/lib/mcollective/connector/rabbitmq.ddl +1 -1
- data/lib/mcollective/data/agent_data.ddl +1 -1
- data/lib/mcollective/data/collective_data.ddl +1 -1
- data/lib/mcollective/data/fact_data.ddl +1 -1
- data/lib/mcollective/data/fstat_data.ddl +1 -1
- data/lib/mcollective/ddl/agentddl.rb +1 -1
- data/lib/mcollective/ddl/dataddl.rb +1 -1
- data/lib/mcollective/ddl/discoveryddl.rb +1 -1
- data/lib/mcollective/discovery/flatfile.ddl +1 -1
- data/lib/mcollective/discovery/mc.ddl +1 -1
- data/lib/mcollective/discovery/stdin.ddl +1 -1
- data/lib/mcollective/matcher.rb +18 -10
- data/lib/mcollective/rpc/agent.rb +1 -1
- data/lib/mcollective/validator/array_validator.ddl +1 -1
- data/lib/mcollective/validator/ipv4address_validator.ddl +1 -1
- data/lib/mcollective/validator/ipv6address_validator.ddl +1 -1
- data/lib/mcollective/validator/length_validator.ddl +1 -1
- data/lib/mcollective/validator/regex_validator.ddl +1 -1
- data/lib/mcollective/validator/shellsafe_validator.ddl +1 -1
- data/lib/mcollective/validator/typecheck_validator.ddl +1 -1
- data/spec/unit/mcollective/matcher_spec.rb +16 -0
- metadata +2 -2
data/lib/mcollective.rb
CHANGED
@@ -15,7 +15,7 @@ module MCollective
|
|
15
15
|
:timeout => @timeout,
|
16
16
|
:name => "Discovery Agent",
|
17
17
|
:version => MCollective.version,
|
18
|
-
:url => "
|
18
|
+
:url => "https://docs.puppetlabs.com/mcollective/",
|
19
19
|
:description => "MCollective Discovery Agent"}
|
20
20
|
end
|
21
21
|
|
@@ -3,7 +3,7 @@ metadata :name => "rpcutil",
|
|
3
3
|
:author => "R.I.Pienaar <rip@devco.net>",
|
4
4
|
:license => "Apache License, Version 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/",
|
7
7
|
:timeout => 10
|
8
8
|
|
9
9
|
action "collective_info", :description => "Info about the main and sub collectives" do
|
@@ -3,7 +3,7 @@ metadata :name => "average",
|
|
3
3
|
:author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/plugin_directory/",
|
7
7
|
:timeout => 5
|
8
8
|
|
9
9
|
usage <<-USAGE
|
@@ -3,7 +3,7 @@ metadata :name => "Sum",
|
|
3
3
|
:author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/plugin_directory/",
|
7
7
|
:timeout => 5
|
8
8
|
|
9
9
|
usage <<-USAGE
|
@@ -3,7 +3,7 @@ metadata :name => "summary",
|
|
3
3
|
:author => "Pieter Loubser <pieter.loubser@puppetlabs.com>",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/plugin_directory/",
|
7
7
|
:timeout => 5
|
8
8
|
|
9
9
|
usage <<-USAGE
|
@@ -3,7 +3,7 @@ metadata :name => "ActiveMQ Connector",
|
|
3
3
|
:author => "Puppet Labs",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/plugin_directory/",
|
7
7
|
:timeout => 60
|
8
8
|
|
9
9
|
requires :mcollective => "2.6.0"
|
@@ -3,7 +3,7 @@ metadata :name => "RabbitMQ Connector",
|
|
3
3
|
:author => "Puppet Labs",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/plugin_directory/",
|
7
7
|
:timeout => 60
|
8
8
|
|
9
9
|
requires :mcollective => "2.6.0"
|
@@ -3,7 +3,7 @@ metadata :name => "Agent",
|
|
3
3
|
:author => "R.I.Pienaar <rip@devco.net>",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/",
|
7
7
|
:timeout => 1
|
8
8
|
|
9
9
|
dataquery :description => "Agent Meta Data" do
|
@@ -3,7 +3,7 @@ metadata :name => "Collective",
|
|
3
3
|
:author => "Puppet Labs",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/",
|
7
7
|
:timeout => 1
|
8
8
|
|
9
9
|
dataquery :description => "Collective" do
|
@@ -3,7 +3,7 @@ metadata :name => "File Stat",
|
|
3
3
|
:author => "R.I.Pienaar <rip@devco.net>",
|
4
4
|
:license => "ASL 2.0",
|
5
5
|
:version => "1.0",
|
6
|
-
:url => "
|
6
|
+
:url => "https://docs.puppetlabs.com/mcollective/",
|
7
7
|
:timeout => 1
|
8
8
|
|
9
9
|
dataquery :description => "File stat information" do
|
@@ -9,7 +9,7 @@ module MCollective
|
|
9
9
|
# :author => "R.I.Pienaar <rip@devco.net>",
|
10
10
|
# :license => "Apache License, Version 2.0",
|
11
11
|
# :version => "1.0",
|
12
|
-
# :url => "
|
12
|
+
# :url => "https://docs.puppetlabs.com/mcollective/",
|
13
13
|
# :timeout => 10
|
14
14
|
#
|
15
15
|
# action "get_fact", :description => "Retrieve a single fact from the fact store" do
|
@@ -10,7 +10,7 @@ module MCollective
|
|
10
10
|
# :author => "R.I.Pienaar <rip@devco.net>",
|
11
11
|
# :license => "ASL 2.0",
|
12
12
|
# :version => "1.0",
|
13
|
-
# :url => "
|
13
|
+
# :url => "https://docs.puppetlabs.com/mcollective/",
|
14
14
|
# :timeout => 1
|
15
15
|
#
|
16
16
|
# dataquery :description => "Agent Meta Data" do
|
data/lib/mcollective/matcher.rb
CHANGED
@@ -134,14 +134,20 @@ module MCollective
|
|
134
134
|
# includes a function
|
135
135
|
def self.eval_compound_fstatement(function_hash)
|
136
136
|
l_compare = execute_function(function_hash)
|
137
|
+
r_compare = function_hash["r_compare"]
|
138
|
+
operator = function_hash["operator"]
|
137
139
|
|
138
140
|
# Break out early and return false if the function returns nil
|
139
|
-
|
141
|
+
if l_compare.nil?
|
142
|
+
return false
|
143
|
+
end
|
140
144
|
|
141
145
|
# Prevent unwanted discovery by limiting comparison operators
|
142
146
|
# on Strings and Booleans
|
143
|
-
if((l_compare.is_a?(String) || l_compare.is_a?(TrueClass) ||
|
144
|
-
|
147
|
+
if((l_compare.is_a?(String) || l_compare.is_a?(TrueClass) ||
|
148
|
+
l_compare.is_a?(FalseClass)) && function_hash["operator"].match(/<|>/))
|
149
|
+
Log.debug("Cannot do > and < comparison on Booleans and Strings " +
|
150
|
+
"'#{l_compare} #{function_hash["operator"]} #{function_hash["r_compare"]}'")
|
145
151
|
return false
|
146
152
|
end
|
147
153
|
|
@@ -152,28 +158,30 @@ module MCollective
|
|
152
158
|
end
|
153
159
|
|
154
160
|
# Escape strings for evaluation
|
155
|
-
|
161
|
+
if (l_compare.is_a?(String) && !(function_hash["operator"] =~ /=~|!=~/))
|
162
|
+
r_compare = "\"#{r_compare}\""
|
163
|
+
end
|
156
164
|
|
157
165
|
# Do a regex comparison if right compare string is a regex
|
158
|
-
if
|
166
|
+
if operator=~ /(=~|!=~)/
|
159
167
|
# Fail if left compare value isn't a string
|
160
168
|
unless l_compare.is_a?(String)
|
161
169
|
Log.debug("Cannot do a regex check on a non string value.")
|
162
170
|
return false
|
163
171
|
else
|
164
|
-
|
172
|
+
result = l_compare.match(r_compare)
|
165
173
|
# Flip return value for != operator
|
166
174
|
if function_hash["operator"] == "!=~"
|
167
|
-
!
|
175
|
+
return !result
|
168
176
|
else
|
169
|
-
|
177
|
+
return !!result
|
170
178
|
end
|
171
179
|
end
|
172
180
|
# Otherwise evaluate the logical comparison
|
173
181
|
else
|
174
182
|
l_compare = "\"#{l_compare}\"" if l_compare.is_a?(String)
|
175
|
-
result = eval("#{l_compare} #{
|
176
|
-
|
183
|
+
result = eval("#{l_compare} #{operator} #{r_compare}")
|
184
|
+
return result
|
177
185
|
end
|
178
186
|
end
|
179
187
|
|
@@ -4,7 +4,7 @@ module MCollective
|
|
4
4
|
# you would do for each agent allowing you to just create methods following a naming
|
5
5
|
# standard leaving the heavy lifting up to this clas.
|
6
6
|
#
|
7
|
-
# See
|
7
|
+
# See https://docs.puppetlabs.com/mcollective/simplerpc/agents.html
|
8
8
|
#
|
9
9
|
# It only really makes sense to use this with a Simple RPC client on the other end, basic
|
10
10
|
# usage would be:
|
@@ -230,6 +230,14 @@ module MCollective
|
|
230
230
|
result.should == true
|
231
231
|
end
|
232
232
|
|
233
|
+
it "should return false if right value is a regex and matches the left value and !=~ is the operator" do
|
234
|
+
Matcher.expects(:execute_function).returns("teststring")
|
235
|
+
@function_hash["r_compare"] = /teststring/
|
236
|
+
@function_hash["operator"] = "!=~"
|
237
|
+
result = Matcher.eval_compound_fstatement(@function_hash)
|
238
|
+
result.should == false
|
239
|
+
end
|
240
|
+
|
233
241
|
it "should return false if right value is a regex, operator is != and regex equals left value" do
|
234
242
|
Matcher.expects(:execute_function).returns("teststring")
|
235
243
|
@function_hash["r_compare"] = /teststring/
|
@@ -254,6 +262,14 @@ module MCollective
|
|
254
262
|
result.should == true
|
255
263
|
end
|
256
264
|
|
265
|
+
it "should return true if we do a false=false comparison" do
|
266
|
+
Matcher.expects(:execute_function).returns(false)
|
267
|
+
@function_hash["r_compare"] = false
|
268
|
+
@function_hash["operator"] = "=="
|
269
|
+
result = Matcher.eval_compound_fstatement(@function_hash)
|
270
|
+
result.should == true
|
271
|
+
end
|
272
|
+
|
257
273
|
it "should return false if left value does not logically compare to right value" do
|
258
274
|
Matcher.expects(:execute_function).returns("1")
|
259
275
|
@function_hash["r_compare"] = "1"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcollective-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: systemu
|