testlab 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/tl CHANGED
@@ -161,6 +161,45 @@ command :network do |c|
161
161
  c.arg_name 'network'
162
162
  c.flag [:i, :id]
163
163
 
164
+
165
+ # ROUTES
166
+ #########
167
+ c.desc 'Manage routes'
168
+ c.command :route do |route|
169
+
170
+ # ROUTE ADD
171
+ ############
172
+ route.desc 'Add routes to lab networks'
173
+ route.command :add do |add|
174
+ add.action do |global_options,options,args|
175
+ help_now!('id is required') if options[:id].nil?
176
+
177
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
178
+ network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
179
+
180
+ network.manage_route(:add)
181
+ @testlab.ui.stdout.puts("Added routes successfully!".green.bold)
182
+ @testlab.ui.stdout.puts %x(netstat -nr | grep '#{network.node.ip}').strip
183
+ end
184
+ end
185
+
186
+ # ROUTE DEL
187
+ ############
188
+ route.desc 'Delete routes to lab networks'
189
+ route.command :del do |del|
190
+ del.action do |global_options,options,args|
191
+ help_now!('id is required') if options[:id].nil?
192
+
193
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
194
+ network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
195
+
196
+ network.manage_route(:del)
197
+ @testlab.ui.stdout.puts("Deleted routes successfully!".red.bold)
198
+ @testlab.ui.stdout.puts %x(netstat -nr | grep '#{network.node.ip}').strip
199
+ end
200
+ end
201
+ end
202
+
164
203
  # NETWORK STATUS
165
204
  #################
166
205
  c.desc 'Display the status of network(s)'
@@ -309,38 +348,6 @@ EOF
309
348
 
310
349
  end
311
350
 
312
- # ROUTES
313
- #########
314
- desc 'Manage routes'
315
- command :route do |c|
316
-
317
- # ROUTE ADD
318
- ############
319
- c.desc 'Add routes to lab networks'
320
- c.command :add do |add|
321
- add.action do |global_options,options,args|
322
- @testlab.nodes.each do |node|
323
- node.route_setup(:add)
324
- @testlab.ui.stdout.puts("Added routes successfully!".green.bold)
325
- @testlab.ui.stdout.puts %x(netstat -nr | grep '#{node.ip}').strip
326
- end
327
- end
328
- end
329
-
330
- # ROUTE DEL
331
- ############
332
- c.desc 'Delete routes to lab networks'
333
- c.command :del do |del|
334
- del.action do |global_options,options,args|
335
- @testlab.nodes.each do |node|
336
- node.route_setup(:del)
337
- @testlab.ui.stdout.puts("Deleted routes successfully!".red.bold)
338
- @testlab.ui.stdout.puts %x(netstat -nr | grep '#{node.ip}').strip
339
- end
340
- end
341
- end
342
- end
343
-
344
351
  pre do |global,command,options,args|
345
352
  # Pre logic here
346
353
  # Return true to proceed; false to abort and not call the
@@ -9,28 +9,27 @@ class TestLab
9
9
 
10
10
  self.create
11
11
  self.up
12
- self.route and route(:add)
12
+ self.route and manage_route(:add)
13
13
  end
14
14
 
15
15
  # Network Teardown
16
16
  def teardown
17
17
  @ui.logger.debug { "Network Teardown: #{self.id} " }
18
18
 
19
- self.route and route(:del)
19
+ self.route and manage_route(:del)
20
20
  self.down
21
21
  self.destroy
22
22
  end
23
23
 
24
- def route(action)
25
- self.networks.each do |network|
26
- command = ZTK::Command.new(:ui => @ui, :silence => true, :ignore_exit_status => true)
24
+ def manage_route(action)
25
+ command = ZTK::Command.new(:ui => @ui, :silence => true, :ignore_exit_status => true)
27
26
 
28
- case RUBY_PLATFORM
29
- when /darwin/ then
30
- command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(network.address)} #{network.node.ip} #{TestLab::Utility.netmask(network.address)}))
31
- when /linux/ then
32
- command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(network.address)} netmask #{TestLab::Utility.netmask(network.address)} gw #{network.node.ip}))
33
- end
27
+ case RUBY_PLATFORM
28
+ when /darwin/ then
29
+ action = ((action == :del) ? :delete : :add)
30
+ command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(self.address)} #{self.node.ip} #{TestLab::Utility.netmask(self.address)}))
31
+ when /linux/ then
32
+ command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(self.address)} netmask #{TestLab::Utility.netmask(self.address)} gw #{self.node.ip}))
34
33
  end
35
34
  end
36
35
 
@@ -38,8 +38,6 @@ class TestLab
38
38
 
39
39
  # ensure our vagrant key is there
40
40
  @config[:vagrant] ||= Hash.new
41
-
42
- render_vagrantfile
43
41
  end
44
42
 
45
43
  ################################################################################
@@ -174,6 +172,7 @@ class TestLab
174
172
  command = TestLab.build_command_line("vagrant", *args)
175
173
  @ui.logger.debug { "command == #{command.inspect}" }
176
174
 
175
+ render_vagrantfile
177
176
  ZTK::Command.new(:ui => @ui, :silence => true).exec(command)
178
177
  end
179
178
 
@@ -16,6 +16,8 @@ class TestLab
16
16
 
17
17
  @config[:version] ||= %(latest)
18
18
  @config[:omnibus_url] ||= %(https://www.opscode.com/chef/install.sh)
19
+
20
+ @ui.logger.debug { "config(#{@config.inspect})" }
19
21
  end
20
22
 
21
23
  # OmniBus Provisioner Container Setup
@@ -18,6 +18,8 @@ class TestLab
18
18
  @config[:version] ||= "latest"
19
19
  @config[:prereleases] ||= false
20
20
  @config[:nightlies] ||= false
21
+
22
+ @ui.logger.debug { "config(#{@config.inspect})" }
21
23
  end
22
24
 
23
25
  # OmniTruck Provisioner Container Setup
@@ -3,4 +3,4 @@ cd /tmp
3
3
  apt-get -y install wget || yum -y install wget
4
4
  rm -fv /tmp/install.sh
5
5
  wget -v --no-check-certificate <%= @omnibus_url %> -O /tmp/install.sh
6
- /bin/bash /tmp/install.sh -v <%= @version -%>
6
+ /bin/bash /tmp/install.sh -v <%= @version %>
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
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: 2013-05-13 00:00:00.000000000 Z
12
+ date: 2013-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -281,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  segments:
283
283
  - 0
284
- hash: 3337879606359400445
284
+ hash: 3482118721192015302
285
285
  required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  none: false
287
287
  requirements:
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  segments:
292
292
  - 0
293
- hash: 3337879606359400445
293
+ hash: 3482118721192015302
294
294
  requirements: []
295
295
  rubyforge_project:
296
296
  rubygems_version: 1.8.25