testlab 0.6.17 → 0.7.0
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/Rakefile +1 -1
- data/bin/tl +21 -7
- data/lib/testlab/container/io.rb +2 -2
- data/lib/testlab/labfile.rb +6 -0
- data/lib/testlab/node.rb +4 -0
- data/lib/testlab/providers/local.rb +1 -1
- data/lib/testlab/providers/vagrant.rb +1 -1
- data/lib/testlab/provisioners/apt_cacher_ng.rb +3 -3
- data/lib/testlab/provisioners/bind.rb +2 -2
- data/lib/testlab/provisioners/resolv.rb +1 -1
- data/lib/testlab/version.rb +1 -1
- data/lib/testlab.rb +22 -18
- metadata +4 -4
data/Rakefile
CHANGED
@@ -39,7 +39,7 @@ require 'yard'
|
|
39
39
|
require 'yard/rake/yardoc_task'
|
40
40
|
|
41
41
|
GEM_NAME = File.basename(Dir.pwd)
|
42
|
-
DOC_PATH = File.expand_path(File.join("..", "
|
42
|
+
DOC_PATH = File.expand_path(File.join("..", "", "#{GEM_NAME}.doc"))
|
43
43
|
|
44
44
|
namespace :doc do
|
45
45
|
YARD::Rake::YardocTask.new(:pages) do |t|
|
data/bin/tl
CHANGED
@@ -51,22 +51,36 @@ arg_name 'path/to/file'
|
|
51
51
|
default_value File.join(Dir.pwd, 'Labfile')
|
52
52
|
flag [:l, :labfile]
|
53
53
|
|
54
|
+
desc 'Path to configuration directory'
|
55
|
+
arg_name 'path/to/directory'
|
56
|
+
default_value File.join(Dir.pwd, ".testlab-#{HOSTNAME}")
|
57
|
+
flag [:c, :config]
|
58
|
+
|
54
59
|
pre do |global,command,options,args|
|
55
|
-
(global[:verbose] == true) and ENV['LOG_LEVEL'] = 'DEBUG'
|
60
|
+
(global[:verbose] == true) and (ENV['LOG_LEVEL'] = 'DEBUG')
|
56
61
|
|
57
62
|
log_file = File.join(Dir.pwd, "testlab-#{HOSTNAME}.log")
|
58
63
|
@logger = ZTK::Logger.new(log_file)
|
59
64
|
|
60
|
-
@
|
61
|
-
@logger
|
62
|
-
|
65
|
+
@ui = ZTK::UI.new(
|
66
|
+
:logger => @logger,
|
67
|
+
:verbose => global[:verbose],
|
68
|
+
:quiet => global[:quiet]
|
69
|
+
)
|
70
|
+
|
71
|
+
@testlab = TestLab.new(
|
72
|
+
:ui => @ui,
|
73
|
+
:labfile => global[:labfile],
|
74
|
+
:config_dir => global[:config]
|
75
|
+
)
|
63
76
|
|
64
|
-
@ui
|
65
|
-
@
|
77
|
+
@ui.logger.debug { "global(#{global.inspect})" }
|
78
|
+
@ui.logger.debug { "options(#{options.inspect})" }
|
79
|
+
@ui.logger.debug { "args(#{args.inspect})" }
|
66
80
|
|
67
81
|
TestLab::Utility.log_header(@testlab).each { |line| @logger.info { line } }
|
68
82
|
|
69
|
-
if
|
83
|
+
if !@ui.quiet?
|
70
84
|
message = format_message("TestLab v#{TestLab::VERSION} Loaded".black.bold)
|
71
85
|
@testlab.ui.stdout.puts(message)
|
72
86
|
end
|
data/lib/testlab/container/io.rb
CHANGED
@@ -14,7 +14,7 @@ class TestLab
|
|
14
14
|
|
15
15
|
self.down
|
16
16
|
|
17
|
-
sc_file =
|
17
|
+
sc_file = %(/tmp/#{self.id}.sc)
|
18
18
|
local_file ||= File.join(Dir.pwd, File.basename(sc_file))
|
19
19
|
|
20
20
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Compress', :cyan)) do
|
@@ -48,7 +48,7 @@ EOF
|
|
48
48
|
self.down
|
49
49
|
self.destroy
|
50
50
|
|
51
|
-
sc_file =
|
51
|
+
sc_file = %(/tmp/#{self.id}.sc)
|
52
52
|
|
53
53
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Import', :cyan)) do
|
54
54
|
self.node.ssh.exec(%(sudo rm -fv #{sc_file}), :silence => true, :ignore_exit_status => true)
|
data/lib/testlab/labfile.rb
CHANGED
@@ -7,9 +7,15 @@ class TestLab
|
|
7
7
|
#
|
8
8
|
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
9
9
|
class Labfile < ZTK::DSL::Base
|
10
|
+
attribute :testlab
|
10
11
|
has_many :nodes, :class_name => 'TestLab::Node'
|
11
12
|
|
12
13
|
attribute :config, :default => Hash.new
|
14
|
+
|
15
|
+
def config_dir
|
16
|
+
self.testlab.config_dir
|
17
|
+
end
|
18
|
+
|
13
19
|
end
|
14
20
|
|
15
21
|
end
|
data/lib/testlab/node.rb
CHANGED
@@ -131,7 +131,7 @@ class TestLab
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def identity
|
134
|
-
(@config[:vagrant][:identity] || File.join(
|
134
|
+
(@config[:vagrant][:identity] || File.join(Dir.home, ".vagrant.d", "insecure_private_key"))
|
135
135
|
end
|
136
136
|
|
137
137
|
def ip
|
@@ -42,7 +42,7 @@ class TestLab
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
apt_conf_d_proxy_file =
|
45
|
+
apt_conf_d_proxy_file = %(/etc/apt/apt.conf.d/00proxy)
|
46
46
|
node.ssh.file(:target => apt_conf_d_proxy_file, :chown => "root:root", :chmod => "0644") do |file|
|
47
47
|
file.puts(ZTK::Template.render(@apt_conf_d_proxy_file_template, context))
|
48
48
|
end
|
@@ -60,7 +60,7 @@ class TestLab
|
|
60
60
|
|
61
61
|
# Ensure the container APT calls use apt-cacher-ng on the node
|
62
62
|
gateway_ip = container.primary_interface.network.ip
|
63
|
-
apt_conf_d_proxy_file =
|
63
|
+
apt_conf_d_proxy_file = %(/etc/apt/apt.conf.d/00proxy)
|
64
64
|
|
65
65
|
@config[:apt][:cacher_ng] = { :proxy_url => "http://#{gateway_ip}:3142" }.merge(@config[:apt][:cacher_ng])
|
66
66
|
|
@@ -69,7 +69,7 @@ class TestLab
|
|
69
69
|
end
|
70
70
|
|
71
71
|
# Fix the APT sources since LXC mudges them when using apt-cacher-ng
|
72
|
-
apt_conf_sources_file =
|
72
|
+
apt_conf_sources_file = %(/etc/apt/sources.list)
|
73
73
|
container.ssh.exec(%(sudo sed -i 's/127.0.0.1:3142\\///g' #{apt_conf_sources_file}))
|
74
74
|
end
|
75
75
|
|
@@ -92,7 +92,7 @@ class TestLab
|
|
92
92
|
def build_bind_db(ssh, zone, records)
|
93
93
|
bind_db_template = File.join(TestLab::Provisioner.template_dir, "bind", 'bind-db.erb')
|
94
94
|
|
95
|
-
ssh.file(:target =>
|
95
|
+
ssh.file(:target => %(/etc/bind/db.#{zone}), :chown => "bind:bind") do |file|
|
96
96
|
file.puts(ZTK::Template.do_not_edit_notice(:message => "TestLab v#{TestLab::VERSION} BIND DB: #{zone}", :char => ';'))
|
97
97
|
file.puts(ZTK::Template.render(bind_db_template, { :zone => zone, :records => records }))
|
98
98
|
end
|
@@ -100,7 +100,7 @@ class TestLab
|
|
100
100
|
|
101
101
|
# Builds the BIND configuration
|
102
102
|
def build_bind_conf(ssh)
|
103
|
-
ssh.file(:target =>
|
103
|
+
ssh.file(:target => %(/etc/bind/named.conf), :chown => "bind:bind") do |file|
|
104
104
|
build_bind_main_partial(file)
|
105
105
|
build_bind_zone_partial(ssh, file)
|
106
106
|
end
|
@@ -49,7 +49,7 @@ class TestLab
|
|
49
49
|
def render_resolv_conf(object)
|
50
50
|
resolv_conf_template = File.join(TestLab::Provisioner.template_dir, "resolv", "resolv.conf.erb")
|
51
51
|
|
52
|
-
object.ssh.file(:target =>
|
52
|
+
object.ssh.file(:target => %(/etc/resolv.conf), :chown => "root:root") do |file|
|
53
53
|
file.puts(ZTK::Template.do_not_edit_notice(:message => "TestLab v#{TestLab::VERSION} RESOLVER Configuration"))
|
54
54
|
file.puts(ZTK::Template.render(resolv_conf_template, @config))
|
55
55
|
end
|
data/lib/testlab/version.rb
CHANGED
data/lib/testlab.rb
CHANGED
@@ -25,7 +25,7 @@ require 'testlab/monkeys'
|
|
25
25
|
#
|
26
26
|
# config Hash[
|
27
27
|
# :domain => "default.zone",
|
28
|
-
# :repo => File.join(
|
28
|
+
# :repo => File.join(Dir.home, "code", "personal", "testlab-repo")
|
29
29
|
# ]
|
30
30
|
#
|
31
31
|
# node :localhost do
|
@@ -84,6 +84,8 @@ require 'testlab/monkeys'
|
|
84
84
|
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
85
85
|
class TestLab
|
86
86
|
|
87
|
+
HOSTNAME ||= Socket.gethostname.split('.').first.strip
|
88
|
+
|
87
89
|
# TestLab Error Class
|
88
90
|
class TestLabError < StandardError; end
|
89
91
|
|
@@ -100,13 +102,18 @@ class TestLab
|
|
100
102
|
|
101
103
|
include TestLab::Utility::Misc
|
102
104
|
|
105
|
+
attr_accessor :config_dir
|
106
|
+
|
103
107
|
def initialize(options={})
|
104
|
-
self.ui
|
108
|
+
self.ui = (options[:ui] || ZTK::UI.new)
|
109
|
+
self.class.ui = self.ui
|
110
|
+
|
111
|
+
@config_dir = (options[:config_dir] || File.join(Dir.pwd, ".testlab-#{HOSTNAME}"))
|
105
112
|
|
106
|
-
labfile
|
107
|
-
labfile_path
|
108
|
-
@labfile
|
109
|
-
@labfile.
|
113
|
+
labfile = (options[:labfile] || File.join(Dir.pwd, 'Labfile'))
|
114
|
+
labfile_path = ZTK::Locator.find(labfile)
|
115
|
+
@labfile = TestLab::Labfile.load(labfile_path)
|
116
|
+
@labfile.testlab = self
|
110
117
|
end
|
111
118
|
|
112
119
|
# Test Lab Nodes
|
@@ -136,6 +143,15 @@ class TestLab
|
|
136
143
|
TestLab::Network.all
|
137
144
|
end
|
138
145
|
|
146
|
+
# Test Lab Labfile
|
147
|
+
#
|
148
|
+
# Returns our top-level Labfile instance.
|
149
|
+
#
|
150
|
+
# @return [TestLab::Labfile] The top-level Labfile instance.
|
151
|
+
def labfile
|
152
|
+
@labfile
|
153
|
+
end
|
154
|
+
|
139
155
|
# Test Lab Configuration
|
140
156
|
#
|
141
157
|
# The hash defined in our *Labfile* DSL object which represents any high-level
|
@@ -274,18 +290,6 @@ class TestLab
|
|
274
290
|
end
|
275
291
|
end
|
276
292
|
|
277
|
-
# TestLab Configuration Directory
|
278
|
-
#
|
279
|
-
# Returns the path to the test lab configuration directory which is located
|
280
|
-
# off the repo directory under '.testlab'.
|
281
|
-
#
|
282
|
-
# @return [String] The path to the TestLab configuration directory.
|
283
|
-
def config_dir
|
284
|
-
@hostname ||= Socket.gethostname.split('.').first.strip
|
285
|
-
directory = File.join(self.config[:repo], ".testlab-#{@hostname}")
|
286
|
-
File.expand_path(directory, File.dirname(__FILE__))
|
287
|
-
end
|
288
|
-
|
289
293
|
# Provider Method Handler
|
290
294
|
#
|
291
295
|
# Proxies missing provider method calls to all nodes.
|
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
|
+
version: 0.7.0
|
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-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
@@ -303,7 +303,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
303
303
|
version: '0'
|
304
304
|
segments:
|
305
305
|
- 0
|
306
|
-
hash: -
|
306
|
+
hash: -1493470985312203031
|
307
307
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
308
308
|
none: false
|
309
309
|
requirements:
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
312
|
version: '0'
|
313
313
|
segments:
|
314
314
|
- 0
|
315
|
-
hash: -
|
315
|
+
hash: -1493470985312203031
|
316
316
|
requirements: []
|
317
317
|
rubyforge_project:
|
318
318
|
rubygems_version: 1.8.25
|