testlab 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/commands/container.rb +10 -5
- data/lib/testlab/container/io.rb +11 -4
- data/lib/testlab/providers/vagrant.rb +1 -1
- data/lib/testlab/utility/logger.rb +5 -3
- data/lib/testlab/version.rb +1 -1
- metadata +4 -4
data/lib/commands/container.rb
CHANGED
@@ -259,13 +259,18 @@ EOF
|
|
259
259
|
export.arg_name 'level'
|
260
260
|
export.flag [:c, :compression]
|
261
261
|
|
262
|
+
export.desc 'Specify the shipping container file to export to.'
|
263
|
+
# export.default_value nil
|
264
|
+
export.arg_name 'filename'
|
265
|
+
export.flag [:output]
|
266
|
+
|
262
267
|
export.action do |global_options, options, args|
|
263
268
|
help_now!('a name is required') if options[:name].nil?
|
264
269
|
|
265
270
|
container = @testlab.containers.select{ |n| n.id.to_sym == options[:name].to_sym }.first
|
266
271
|
container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
|
267
272
|
|
268
|
-
container.export(options[:compression])
|
273
|
+
container.export(options[:compression], options[:output])
|
269
274
|
end
|
270
275
|
end
|
271
276
|
|
@@ -274,18 +279,18 @@ EOF
|
|
274
279
|
c.desc 'Import a shipping container (file)'
|
275
280
|
c.command :import do |import|
|
276
281
|
|
277
|
-
import.desc 'Specify the shipping container file to import.'
|
282
|
+
import.desc 'Specify the shipping container file to import from.'
|
278
283
|
import.arg_name 'filename'
|
279
|
-
import.flag [:
|
284
|
+
import.flag [:input]
|
280
285
|
|
281
286
|
import.action do |global_options, options, args|
|
282
287
|
help_now!('a name is required') if options[:name].nil?
|
283
|
-
help_now!('a filename is required') if options[:
|
288
|
+
help_now!('a filename is required') if options[:input].nil?
|
284
289
|
|
285
290
|
container = @testlab.containers.select{ |n| n.id.to_sym == options[:name].to_sym }.first
|
286
291
|
container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
|
287
292
|
|
288
|
-
container.import(options[:
|
293
|
+
container.import(options[:input])
|
289
294
|
end
|
290
295
|
end
|
291
296
|
|
data/lib/testlab/container/io.rb
CHANGED
@@ -2,11 +2,12 @@ class TestLab
|
|
2
2
|
class Container
|
3
3
|
|
4
4
|
module IO
|
5
|
+
PBZIP2_MEMORY = 256
|
5
6
|
|
6
7
|
# Export the container
|
7
8
|
#
|
8
9
|
# @return [Boolean] True if successful.
|
9
|
-
def export(compression=9)
|
10
|
+
def export(compression=9, local_file=nil)
|
10
11
|
@ui.logger.debug { "Container Export: #{self.id} " }
|
11
12
|
|
12
13
|
(self.lxc.state == :not_created) and return false
|
@@ -14,14 +15,17 @@ class TestLab
|
|
14
15
|
self.down
|
15
16
|
|
16
17
|
sc_file = File.join("/", "tmp", "#{self.id}.sc")
|
17
|
-
local_file
|
18
|
+
local_file ||= File.join(Dir.pwd, File.basename(sc_file))
|
18
19
|
|
19
20
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Compress', :cyan)) do
|
20
21
|
self.node.ssh.bootstrap(<<-EOF)
|
21
22
|
set -x
|
22
23
|
set -e
|
23
|
-
|
24
|
+
|
25
|
+
du -sh #{self.lxc.container_root}
|
26
|
+
find #{self.lxc.container_root} -print0 -depth | cpio -o0 | pbzip2 -#{compression} -vfczm#{PBZIP2_MEMORY} > #{sc_file}
|
24
27
|
chown ${SUDO_USER}:${SUDO_USER} #{sc_file}
|
28
|
+
ls -lah #{sc_file}
|
25
29
|
EOF
|
26
30
|
end
|
27
31
|
|
@@ -55,7 +59,10 @@ EOF
|
|
55
59
|
self.node.ssh.bootstrap(<<-EOF)
|
56
60
|
set -x
|
57
61
|
set -e
|
58
|
-
|
62
|
+
|
63
|
+
ls -lah #{sc_file}
|
64
|
+
pbzip2 -vdcm#{PBZIP2_MEMORY} #{sc_file} | cpio -uid && rm -fv #{sc_file}
|
65
|
+
du -sh #{self.lxc.container_root}
|
59
66
|
EOF
|
60
67
|
end
|
61
68
|
|
@@ -91,7 +91,7 @@ class TestLab
|
|
91
91
|
|
92
92
|
# Inquire the state of the Vagrant-controlled VM
|
93
93
|
def state
|
94
|
-
output = self.vagrant_cli("status
|
94
|
+
output = self.vagrant_cli("status").output.grep(/#{self.instance_id}/).first
|
95
95
|
result = UNKNOWN_STATE
|
96
96
|
ALL_STATES.map{ |s| s.to_s.gsub('_', ' ') }.each do |state|
|
97
97
|
if output =~ /#{state}/
|
@@ -20,14 +20,12 @@ class TestLab
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def log_details(testlab)
|
23
|
-
@command = ZTK::Command.new(:silence => true, :ignore_exit_status => true)
|
24
23
|
{
|
25
24
|
"hostname" => Socket.gethostname.inspect,
|
26
25
|
"program" => $0.to_s.inspect,
|
27
26
|
"config_dir" => testlab.config_dir.inspect,
|
28
27
|
"logdev" => testlab.ui.logger.logdev.inspect,
|
29
|
-
"
|
30
|
-
"virtualbox_version" => @command.exec(%(/usr/bin/env vboxmanage --version)).output.strip.inspect
|
28
|
+
"version" => TestLab::VERSION
|
31
29
|
}
|
32
30
|
end
|
33
31
|
|
@@ -44,11 +42,15 @@ class TestLab
|
|
44
42
|
end
|
45
43
|
|
46
44
|
def log_dependencies
|
45
|
+
@command = ZTK::Command.new(:silence => true, :ignore_exit_status => true)
|
46
|
+
|
47
47
|
{
|
48
48
|
"gli_version" => ::GLI::VERSION.inspect,
|
49
49
|
"lxc_version" => ::LXC::VERSION.inspect,
|
50
50
|
"ztk_version" => ::ZTK::VERSION.inspect,
|
51
51
|
"activesupport_version" => ::ActiveSupport::VERSION::STRING.inspect,
|
52
|
+
"vagrant_version" => @command.exec(%(/usr/bin/env vagrant --version)).output.strip.inspect,
|
53
|
+
"virtualbox_version" => @command.exec(%(/usr/bin/env vboxmanage --version)).output.strip.inspect
|
52
54
|
}
|
53
55
|
end
|
54
56
|
|
data/lib/testlab/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.8
|
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-06-
|
12
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
@@ -300,7 +300,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
300
300
|
version: '0'
|
301
301
|
segments:
|
302
302
|
- 0
|
303
|
-
hash:
|
303
|
+
hash: 1538648921136541642
|
304
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
305
305
|
none: false
|
306
306
|
requirements:
|
@@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
segments:
|
311
311
|
- 0
|
312
|
-
hash:
|
312
|
+
hash: 1538648921136541642
|
313
313
|
requirements: []
|
314
314
|
rubyforge_project:
|
315
315
|
rubygems_version: 1.8.25
|