testlab 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tl +19 -0
- data/lib/testlab/container/actions.rb +13 -3
- data/lib/testlab/container.rb +3 -3
- data/lib/testlab/version.rb +1 -1
- metadata +2 -2
data/bin/tl
CHANGED
@@ -374,6 +374,25 @@ EOF
|
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
+
# CONTAINER CLONE
|
378
|
+
##################
|
379
|
+
c.desc 'Clone a container'
|
380
|
+
c.long_desc <<-EOF
|
381
|
+
Clone a container. The container is offlined and an ephemeral copy of it is started.
|
382
|
+
EOF
|
383
|
+
c.command :clone do |clone|
|
384
|
+
clone.action do |global_options, options, args|
|
385
|
+
if options[:id].nil?
|
386
|
+
help_now!('id is required') if options[:id].nil?
|
387
|
+
else
|
388
|
+
container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
|
389
|
+
container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
|
390
|
+
|
391
|
+
container.clone
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
377
396
|
end
|
378
397
|
|
379
398
|
pre do |global,command,options,args|
|
@@ -14,9 +14,6 @@ class TestLab
|
|
14
14
|
|
15
15
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do
|
16
16
|
self.domain ||= self.node.labfile.config[:domain]
|
17
|
-
self.distro ||= "ubuntu"
|
18
|
-
self.release ||= "precise"
|
19
|
-
|
20
17
|
self.arch ||= detect_arch
|
21
18
|
|
22
19
|
self.lxc.config.clear
|
@@ -78,6 +75,7 @@ class TestLab
|
|
78
75
|
(self.lxc.state == :not_created) and return false #raise ContainerError, "We can not online a non-existant container!"
|
79
76
|
|
80
77
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
|
78
|
+
self.lxc.lxc.exec(%(lxc-stop), %(-n #{self.id}-clone))
|
81
79
|
self.lxc.start
|
82
80
|
self.lxc.wait(:running)
|
83
81
|
|
@@ -101,6 +99,7 @@ class TestLab
|
|
101
99
|
(self.lxc.state == :not_created) and return false # raise ContainerError, "We can not offline a non-existant container!"
|
102
100
|
|
103
101
|
please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do
|
102
|
+
self.lxc.lxc.exec(%(lxc-stop), %(-n #{self.id}-clone))
|
104
103
|
self.lxc.stop
|
105
104
|
self.lxc.wait(:stopped)
|
106
105
|
|
@@ -110,6 +109,17 @@ class TestLab
|
|
110
109
|
true
|
111
110
|
end
|
112
111
|
|
112
|
+
def clone
|
113
|
+
@ui.logger.debug { "Container Clone: #{self.id}" }
|
114
|
+
|
115
|
+
self.down
|
116
|
+
|
117
|
+
please_wait(:ui => @ui, :message => format_object_action(self, 'Clone', :yellow)) do
|
118
|
+
self.lxc.start_ephemeral(%(-o #{self.id} -n #{self.id}-clone), %(-d))
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
113
123
|
end
|
114
124
|
|
115
125
|
end
|
data/lib/testlab/container.rb
CHANGED
@@ -15,7 +15,7 @@ class TestLab
|
|
15
15
|
# release "precise"
|
16
16
|
#
|
17
17
|
# interface do
|
18
|
-
# network_id
|
18
|
+
# network_id 'west'
|
19
19
|
# name :eth0
|
20
20
|
# address '10.11.0.254/16'
|
21
21
|
# mac '00:00:5e:48:e9:6f'
|
@@ -28,14 +28,14 @@ class TestLab
|
|
28
28
|
# release "precise"
|
29
29
|
#
|
30
30
|
# interface do
|
31
|
-
# network_id
|
31
|
+
# network_id 'east'
|
32
32
|
# name :eth0
|
33
33
|
# address '10.10.0.200/16'
|
34
34
|
# mac '00:00:5e:63:b5:9f'
|
35
35
|
# end
|
36
36
|
#
|
37
37
|
# interface do
|
38
|
-
# network_id
|
38
|
+
# network_id 'west'
|
39
39
|
# primary true
|
40
40
|
# name :eth1
|
41
41
|
# address '10.11.0.200/16'
|
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.4.
|
4
|
+
version: 0.4.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-05-
|
12
|
+
date: 2013-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|