mcollective-client 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mcollective/pluginpackager/agent_definition.rb +3 -3
- data/lib/mcollective/pluginpackager/standard_definition.rb +2 -2
- data/lib/mcollective/rpc/client.rb +38 -9
- data/spec/unit/pluginpackager/agent_definition_spec.rb +19 -7
- data/spec/unit/pluginpackager/standard_definition_spec.rb +12 -2
- data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +5 -0
- data/spec/unit/rpc/client_spec.rb +33 -2
- metadata +4 -4
|
@@ -20,7 +20,7 @@ module MCollective
|
|
|
20
20
|
@mcversion = mcdependency[:mcversion] || mcversion
|
|
21
21
|
@dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
|
|
22
22
|
|
|
23
|
-
@metadata[:name] = (name || @metadata[:name]).downcase.gsub(
|
|
23
|
+
@metadata[:name] = (name || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
|
24
24
|
identify_packages
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -48,7 +48,7 @@ module MCollective
|
|
|
48
48
|
else
|
|
49
49
|
return nil
|
|
50
50
|
end
|
|
51
|
-
agent[:
|
|
51
|
+
agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :iteration => @iteration}
|
|
52
52
|
agent
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -63,7 +63,7 @@ module MCollective
|
|
|
63
63
|
|
|
64
64
|
client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
|
|
65
65
|
client[:files] += Dir.glob(File.join(aggregatedir, "*")) if PluginPackager.check_dir_present aggregatedir
|
|
66
|
-
client[:
|
|
66
|
+
client[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :iteration => @iteration}
|
|
67
67
|
client[:files].empty? ? nil : client
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -19,7 +19,7 @@ module MCollective
|
|
|
19
19
|
@mcname = mcdependency[:mcname] || "mcollective"
|
|
20
20
|
@mcversion = mcdependency[:mcversion] || mcversion
|
|
21
21
|
@dependencies << {:name => "#{mcname}-common", :version => @mcversion}
|
|
22
|
-
@metadata[:name] = (name || @metadata[:name]).downcase.gsub(
|
|
22
|
+
@metadata[:name] = (name || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
|
|
23
23
|
identify_packages
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -44,7 +44,7 @@ module MCollective
|
|
|
44
44
|
return nil
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
plugindata[:
|
|
47
|
+
plugindata[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common",
|
|
48
48
|
:version => @metadata[:version],
|
|
49
49
|
:iteration => @iteration} if @packagedata[:common]
|
|
50
50
|
plugindata
|
|
@@ -39,12 +39,16 @@ module MCollective
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
@initial_options = initial_options
|
|
42
|
+
|
|
43
|
+
@config = initial_options[:config]
|
|
44
|
+
@client = MCollective::Client.new(@config)
|
|
45
|
+
@client.options = initial_options
|
|
46
|
+
|
|
42
47
|
@stats = Stats.new
|
|
43
48
|
@agent = agent
|
|
44
49
|
@timeout = initial_options[:timeout] || 5
|
|
45
50
|
@verbose = initial_options[:verbose]
|
|
46
51
|
@filter = initial_options[:filter] || Util.empty_filter
|
|
47
|
-
@config = initial_options[:config]
|
|
48
52
|
@discovered_agents = nil
|
|
49
53
|
@progress = initial_options[:progress_bar]
|
|
50
54
|
@limit_targets = initial_options[:mcollective_limit_targets]
|
|
@@ -63,10 +67,7 @@ module MCollective
|
|
|
63
67
|
|
|
64
68
|
agent_filter agent
|
|
65
69
|
|
|
66
|
-
@
|
|
67
|
-
@client.options = initial_options
|
|
68
|
-
|
|
69
|
-
@discovery_timeout = discovery_timeout
|
|
70
|
+
@discovery_timeout = @initial_options.fetch(:disctimeout, nil)
|
|
70
71
|
|
|
71
72
|
@collective = @client.collective
|
|
72
73
|
@ttl = initial_options[:ttl] || Config.instance.ttl
|
|
@@ -88,7 +89,7 @@ module MCollective
|
|
|
88
89
|
# DDLs are required, failure to find a DDL is fatal
|
|
89
90
|
@ddl = DDL.new(agent)
|
|
90
91
|
@stats.ddl = @ddl
|
|
91
|
-
@timeout = @ddl.meta[:timeout] +
|
|
92
|
+
@timeout = @ddl.meta[:timeout] + discovery_timeout if @timeout == 5
|
|
92
93
|
|
|
93
94
|
# allows stderr and stdout to be overridden for testing
|
|
94
95
|
# but also for web apps that might not want a bunch of stuff
|
|
@@ -321,10 +322,38 @@ module MCollective
|
|
|
321
322
|
end
|
|
322
323
|
|
|
323
324
|
def discovery_timeout
|
|
324
|
-
return @
|
|
325
|
+
return @discovery_timeout if @discovery_timeout
|
|
325
326
|
return @client.discoverer.ddl.meta[:timeout]
|
|
326
327
|
end
|
|
327
328
|
|
|
329
|
+
def discovery_timeout=(timeout)
|
|
330
|
+
@discovery_timeout = Float(timeout)
|
|
331
|
+
|
|
332
|
+
# we calculate the overall timeout from the DDL of the agent and
|
|
333
|
+
# the supplied discovery timeout unless someone specifically
|
|
334
|
+
# specifies a timeout to the constructor
|
|
335
|
+
#
|
|
336
|
+
# But if we also then specifically set a discovery_timeout on the
|
|
337
|
+
# agent that has to override the supplied timeout so we then
|
|
338
|
+
# calculate a correct timeout based on DDL timeout and the
|
|
339
|
+
# supplied discovery timeout
|
|
340
|
+
@timeout = @ddl.meta[:timeout] + discovery_timeout
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Sets the discovery method. If we change the method there are a
|
|
344
|
+
# number of steps to take:
|
|
345
|
+
#
|
|
346
|
+
# - set the new method
|
|
347
|
+
# - if discovery options were provided, re-set those to initially
|
|
348
|
+
# provided ones else clear them as they might now apply to a
|
|
349
|
+
# different provider
|
|
350
|
+
# - update the client options so it knows there is a new discovery
|
|
351
|
+
# method in force
|
|
352
|
+
# - reset discovery data forcing a discover on the next request
|
|
353
|
+
#
|
|
354
|
+
# The remaining item is the discovery timeout, we leave that as is
|
|
355
|
+
# since that is the user supplied timeout either via initial options
|
|
356
|
+
# or via specifically setting it on the client.
|
|
328
357
|
def discovery_method=(method)
|
|
329
358
|
@discovery_method = method
|
|
330
359
|
|
|
@@ -335,7 +364,7 @@ module MCollective
|
|
|
335
364
|
end
|
|
336
365
|
|
|
337
366
|
@client.options = options
|
|
338
|
-
|
|
367
|
+
|
|
339
368
|
reset
|
|
340
369
|
end
|
|
341
370
|
|
|
@@ -520,7 +549,7 @@ module MCollective
|
|
|
520
549
|
# Provides a normal options hash like you would get from
|
|
521
550
|
# Optionparser
|
|
522
551
|
def options
|
|
523
|
-
{:disctimeout =>
|
|
552
|
+
{:disctimeout => discovery_timeout,
|
|
524
553
|
:timeout => @timeout,
|
|
525
554
|
:verbose => @verbose,
|
|
526
555
|
:filter => @filter,
|
|
@@ -10,24 +10,36 @@ module MCollective
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
describe "#initialize" do
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
before do
|
|
14
15
|
AgentDefinition.any_instance.expects(:common)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should replace spaces in the package name with dashes" do
|
|
15
19
|
agent = AgentDefinition.new(".", "test package", nil, nil, nil, nil, [], {}, "agent")
|
|
16
20
|
agent.metadata[:name].should == "test-package"
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
it "should set dependencies if present" do
|
|
20
|
-
AgentDefinition.any_instance.expects(:common)
|
|
21
24
|
agent = AgentDefinition.new(".", "test-package", nil, nil, nil, nil, [:name => "foo", :version => nil], {}, "agent")
|
|
22
25
|
agent.dependencies.should == [{:name => "foo", :version => nil}, {:name => "mcollective-common", :version => nil}]
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
it "should set mc name and version" do
|
|
26
|
-
AgentDefinition.any_instance.expects(:common)
|
|
27
29
|
agent = AgentDefinition.new(".", "test-package", nil, nil, nil, nil, [], {:mcname =>"pe-mcollective-common", :mcversion =>"1.2"}, "agent")
|
|
28
30
|
agent.mcname.should == "pe-mcollective-common"
|
|
29
31
|
agent.mcversion.should == "1.2"
|
|
30
32
|
end
|
|
33
|
+
|
|
34
|
+
it "should replace underscored with dashes in the name" do
|
|
35
|
+
agent = AgentDefinition.new(".", "test_package", nil, nil, nil, nil, [], {:mcname =>"pe-mcollective-common", :mcversion =>"1.2"}, "agent")
|
|
36
|
+
agent.metadata[:name].should == "test-package"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should replace whitespaces with a single dash in the name" do
|
|
40
|
+
agent = AgentDefinition.new(".", "test package", nil, nil, nil, nil, [], {:mcname =>"pe-mcollective-common", :mcversion =>"1.2"}, "agent")
|
|
41
|
+
agent.metadata[:name].should == "test-package"
|
|
42
|
+
end
|
|
31
43
|
end
|
|
32
44
|
|
|
33
45
|
describe "#identify_packages" do
|
|
@@ -77,8 +89,8 @@ module MCollective
|
|
|
77
89
|
Dir.stubs(:glob).returns([])
|
|
78
90
|
|
|
79
91
|
agent = AgentDefinition.new(".", nil, nil, nil, nil, nil, [], {}, "agent")
|
|
80
|
-
agent.packagedata[:agent][:dependencies].should == [{:name => "mcollective-common", :version => nil}
|
|
81
|
-
|
|
92
|
+
agent.packagedata[:agent][:dependencies].should == [{:name => "mcollective-common", :version => nil}]
|
|
93
|
+
agent.packagedata[:agent][:plugindependency].should == {:name => "mcollective-foo-common", :version =>1, :iteration => 1}
|
|
82
94
|
end
|
|
83
95
|
end
|
|
84
96
|
|
|
@@ -152,8 +164,8 @@ module MCollective
|
|
|
152
164
|
Dir.expects(:glob).with("aggregatedir/*").returns(["aggregate.rb"])
|
|
153
165
|
|
|
154
166
|
client = AgentDefinition.new(".", nil, nil, nil, nil, nil, [], {}, "agent")
|
|
155
|
-
client.packagedata[:client][:dependencies].should == [{:name => "mcollective-common", :version => nil}
|
|
156
|
-
|
|
167
|
+
client.packagedata[:client][:dependencies].should == [{:name => "mcollective-common", :version => nil}]
|
|
168
|
+
client.packagedata[:client][:plugindependency].should == {:name => "mcollective-foo-common", :version => 1, :iteration => 1}
|
|
157
169
|
end
|
|
158
170
|
end
|
|
159
171
|
end
|
|
@@ -26,6 +26,16 @@ module MCollective
|
|
|
26
26
|
plugin.mcname.should == "pe-mcollective"
|
|
27
27
|
plugin.mcversion.should == "1"
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
it "should replace underscores with dashes in the name" do
|
|
31
|
+
plugin = StandardDefinition.new(".", "test_plugin", nil, nil, nil, nil, [], {:mcname => "pe-mcollective", :mcversion => "1"}, "testplugin")
|
|
32
|
+
plugin.metadata[:name].should == "test-plugin"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should replace whitespaces with a single dash in the name" do
|
|
36
|
+
plugin = StandardDefinition.new(".", "test plugin", nil, nil, nil, nil, [], {:mcname => "pe-mcollective", :mcversion => "1"}, "testplugin")
|
|
37
|
+
plugin.metadata[:name].should == "test-plugin"
|
|
38
|
+
end
|
|
29
39
|
end
|
|
30
40
|
|
|
31
41
|
describe "#identify_packages" do
|
|
@@ -62,8 +72,8 @@ module MCollective
|
|
|
62
72
|
Dir.expects(:glob).with("./testplugin/*").returns(["file.rb"])
|
|
63
73
|
plugin = StandardDefinition.new(".", nil, nil, nil, nil, nil, [], {}, "testplugin")
|
|
64
74
|
plugin.packagedata["testplugin"][:files].should == ["file.rb"]
|
|
65
|
-
plugin.packagedata["testplugin"][:dependencies].should == [{:name => "mcollective-common", :version => nil}
|
|
66
|
-
|
|
75
|
+
plugin.packagedata["testplugin"][:dependencies].should == [{:name => "mcollective-common", :version => nil}]
|
|
76
|
+
plugin.packagedata["testplugin"][:plugindependency].should == {:name => "mcollective-foo-common", :version => 1, :iteration => 1}
|
|
67
77
|
end
|
|
68
78
|
end
|
|
69
79
|
|
|
@@ -50,6 +50,11 @@ module MCollective
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
describe "#initialize" do
|
|
53
|
+
it "should be deprecated" do
|
|
54
|
+
Log.expects(:info).with(regexp_matches(/please migrate to the/))
|
|
55
|
+
Stomp.new
|
|
56
|
+
end
|
|
57
|
+
|
|
53
58
|
it "should set the @config variable" do
|
|
54
59
|
c = Stomp.new
|
|
55
60
|
c.instance_variable_get("@config").should == @config
|
|
@@ -50,6 +50,16 @@ module MCollective
|
|
|
50
50
|
|
|
51
51
|
Client.new("foo", :options => {:config => "/nonexisting"})
|
|
52
52
|
end
|
|
53
|
+
|
|
54
|
+
it "should default the discovery_timeout to nil" do
|
|
55
|
+
c = Client.new("rspec", :options => {:config => "/nonexisting"})
|
|
56
|
+
c.instance_variable_get("@discovery_timeout").should == nil
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should accept a supplied discovery_timeout" do
|
|
60
|
+
c = Client.new("rspec", :options => {:config => "/nonexisting", :disctimeout => 10})
|
|
61
|
+
c.instance_variable_get("@discovery_timeout").should == 10
|
|
62
|
+
end
|
|
53
63
|
end
|
|
54
64
|
|
|
55
65
|
describe "#process_results_with_block" do
|
|
@@ -228,10 +238,16 @@ module MCollective
|
|
|
228
238
|
@client.discovery_method = "rspec"
|
|
229
239
|
end
|
|
230
240
|
|
|
231
|
-
it "should adjust
|
|
241
|
+
it "should adjust timeout for the new method" do
|
|
232
242
|
@client.expects(:discovery_timeout).once.returns(1)
|
|
233
243
|
@client.discovery_method = "rspec"
|
|
234
|
-
@client.instance_variable_get("@
|
|
244
|
+
@client.instance_variable_get("@timeout").should == 4
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "should preserve any user supplied discovery timeout" do
|
|
248
|
+
@client.discovery_timeout = 10
|
|
249
|
+
@client.discovery_method = "rspec"
|
|
250
|
+
@client.discovery_timeout.should == 10
|
|
235
251
|
end
|
|
236
252
|
|
|
237
253
|
it "should reset the rpc client" do
|
|
@@ -259,6 +275,21 @@ module MCollective
|
|
|
259
275
|
end
|
|
260
276
|
end
|
|
261
277
|
|
|
278
|
+
describe "#discovery_timeout=" do
|
|
279
|
+
it "should store the discovery timeout" do
|
|
280
|
+
@client.discovery_timeout = 10
|
|
281
|
+
@client.discovery_timeout.should == 10
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
it "should update the overall timeout with the new discovery timeout" do
|
|
285
|
+
@client.instance_variable_get("@timeout").should == 4
|
|
286
|
+
|
|
287
|
+
@client.discovery_timeout = 10
|
|
288
|
+
|
|
289
|
+
@client.instance_variable_get("@timeout").should == 12
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
262
293
|
describe "#limit_method" do
|
|
263
294
|
it "should force strings to symbols" do
|
|
264
295
|
@client.limit_method = "first"
|
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:
|
|
4
|
+
hash: 1
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 2
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 2.2.
|
|
9
|
+
- 3
|
|
10
|
+
version: 2.2.3
|
|
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: 2013-
|
|
18
|
+
date: 2013-02-14 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: systemu
|