testlab 0.2.0 → 0.2.1
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/bin/tl +32 -1
- data/lib/testlab/node/lifecycle.rb +16 -4
- data/lib/testlab/node.rb +1 -0
- data/lib/testlab/providers/vagrant.rb +2 -2
- data/lib/testlab/version.rb +1 -1
- data/lib/testlab.rb +10 -13
- metadata +4 -4
data/bin/tl
CHANGED
@@ -132,6 +132,32 @@ command :container do |c|
|
|
132
132
|
|
133
133
|
end
|
134
134
|
|
135
|
+
desc 'Manage routes'
|
136
|
+
command :route do |c|
|
137
|
+
|
138
|
+
c.desc 'Add routes to lab networks'
|
139
|
+
c.command :add do |add|
|
140
|
+
add.action do |global_options,options,args|
|
141
|
+
@testlab.nodes.each do |node|
|
142
|
+
node.route_setup(:add)
|
143
|
+
@testlab.ui.stdout.puts("Added routes successfully!".green.bold)
|
144
|
+
@testlab.ui.stdout.puts %x(netstat -nr | grep '#{node.ip}').strip
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
c.desc 'Delete routes to lab networks'
|
150
|
+
c.command :del do |del|
|
151
|
+
del.action do |global_options,options,args|
|
152
|
+
@testlab.nodes.each do |node|
|
153
|
+
node.route_setup(:del)
|
154
|
+
@testlab.ui.stdout.puts("Deleted routes successfully!".red.bold)
|
155
|
+
@testlab.ui.stdout.puts %x(netstat -nr | grep '#{node.ip}').strip
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
135
161
|
pre do |global,command,options,args|
|
136
162
|
# Pre logic here
|
137
163
|
# Return true to proceed; false to abort and not call the
|
@@ -159,7 +185,12 @@ end
|
|
159
185
|
on_error do |exception|
|
160
186
|
# Error logic here
|
161
187
|
# return false to skip default error handling
|
162
|
-
puts(["EXCEPTION:".red.bold, exception.inspect.red].join(' '))
|
188
|
+
@ui.stderr.puts(["EXCEPTION:".red.bold, exception.inspect.red].join(' '))
|
189
|
+
|
190
|
+
@logger.fatal { exception.inspect }
|
191
|
+
exception.backtrace.each do |line|
|
192
|
+
@logger.logdev.write("#{line}\n")
|
193
|
+
end
|
163
194
|
|
164
195
|
false
|
165
196
|
end
|
@@ -28,13 +28,23 @@ class TestLab
|
|
28
28
|
self.ssh.bootstrap(ZTK::Template.render(node_setup_template))
|
29
29
|
end
|
30
30
|
|
31
|
+
def route_setup(action)
|
32
|
+
self.networks.each do |network|
|
33
|
+
command = ZTK::Command.new(:silence => true, :ignore_exit_status => true)
|
34
|
+
command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(network.ip)} netmask #{TestLab::Utility.netmask(network.ip)} gw #{network.node.ip}))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
31
38
|
# Setup the node.
|
32
39
|
def setup
|
33
40
|
@ui.logger.debug { "Node Setup: #{self.id} " }
|
34
41
|
|
35
|
-
# @ui.stdout.puts(format_message(format_object(self, :green)))
|
36
|
-
|
37
42
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Setup', :green)) do
|
43
|
+
|
44
|
+
if (self.route == true)
|
45
|
+
route_setup(:add)
|
46
|
+
end
|
47
|
+
|
38
48
|
node_setup
|
39
49
|
|
40
50
|
if self.components.include?('resolv')
|
@@ -59,11 +69,13 @@ class TestLab
|
|
59
69
|
def teardown
|
60
70
|
@ui.logger.debug { "Node Teardown: #{self.id} " }
|
61
71
|
|
62
|
-
# @ui.stdout.puts(format_message(format_object(self, :red)))
|
63
|
-
|
64
72
|
call_collections([self.containers, self.routers, self.networks], :teardown)
|
65
73
|
|
66
74
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Teardown', :red)) do
|
75
|
+
|
76
|
+
if (self.route == true)
|
77
|
+
route_setup(:del)
|
78
|
+
end
|
67
79
|
end
|
68
80
|
|
69
81
|
true
|
data/lib/testlab/node.rb
CHANGED
@@ -151,11 +151,11 @@ class TestLab
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def box
|
154
|
-
(@config[:vagrant][:box] || "
|
154
|
+
(@config[:vagrant][:box] || "raring64")
|
155
155
|
end
|
156
156
|
|
157
157
|
def box_url
|
158
|
-
(@config[:vagrant][:box_url] || "http://files.vagrantup.com/
|
158
|
+
(@config[:vagrant][:box_url] || "http://files.vagrantup.com/raring64.box")
|
159
159
|
end
|
160
160
|
|
161
161
|
def cpus
|
data/lib/testlab/version.rb
CHANGED
data/lib/testlab.rb
CHANGED
@@ -68,19 +68,16 @@ class TestLab
|
|
68
68
|
|
69
69
|
def status
|
70
70
|
if alive?
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@@ui.stdout.puts("CONTAINERS:".green.bold)
|
82
|
-
ZTK::Report.new(:ui => @@ui).list(TestLab::Container.all, TestLab::Container::STATUS_KEYS) do |container|
|
83
|
-
OpenStruct.new(container.status)
|
71
|
+
%w(nodes networks containers).map(&:to_sym).each do |object_symbol|
|
72
|
+
@@ui.stdout.puts
|
73
|
+
@@ui.stdout.puts("#{object_symbol}:".upcase.green.bold)
|
74
|
+
|
75
|
+
klass = object_symbol.to_s.singularize.capitalize
|
76
|
+
status_keys = "TestLab::#{klass}::STATUS_KEYS".constantize
|
77
|
+
|
78
|
+
ZTK::Report.new(:ui => @@ui).list(self.send(object_symbol), status_keys) do |object|
|
79
|
+
OpenStruct.new(object.status)
|
80
|
+
end
|
84
81
|
end
|
85
82
|
|
86
83
|
true
|
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.2.
|
4
|
+
version: 0.2.1
|
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-
|
12
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
segments:
|
241
241
|
- 0
|
242
|
-
hash:
|
242
|
+
hash: -56474438421071425
|
243
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
244
|
none: false
|
245
245
|
requirements:
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: '0'
|
249
249
|
segments:
|
250
250
|
- 0
|
251
|
-
hash:
|
251
|
+
hash: -56474438421071425
|
252
252
|
requirements: []
|
253
253
|
rubyforge_project:
|
254
254
|
rubygems_version: 1.8.25
|