testlab 0.4.9 → 0.4.10

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.
@@ -71,13 +71,9 @@ class TestLab
71
71
  (self.lxc.state == :not_created) and return false #raise ContainerError, "We can not online a non-existant container!"
72
72
 
73
73
  please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
74
- if self.lxc_clone.exists?
75
- self.lxc.stop
76
- self.lxc_clone.stop
77
- self.lxc_clone.clone(%(-o #{self.id}-master), %(-n #{self.id}))
78
- build_lxc_config(self.lxc.config)
79
- self.lxc_clone.destroy(%(-f))
80
- end
74
+
75
+ # ensure our container is in "static" mode
76
+ self.to_static
81
77
 
82
78
  self.lxc.start
83
79
  self.lxc.wait(:running)
@@ -122,14 +118,11 @@ class TestLab
122
118
  self.down
123
119
 
124
120
  please_wait(:ui => @ui, :message => format_object_action(self, 'Clone', :yellow)) do
125
- if self.lxc.exists?
126
- self.lxc.stop
127
- self.lxc.clone(%(-o #{self.id}), %(-n #{self.id}-master))
128
- build_lxc_config(self.lxc_clone.config)
129
- self.lxc.destroy(%(-f))
130
- end
131
121
 
132
- self.lxc_clone.start_ephemeral(%(-o #{self.id}-master -n #{self.id}), %(-d))
122
+ # ensure our container is in "ephemeral" mode
123
+ self.to_ephemeral
124
+
125
+ self.lxc_clone.start_ephemeral(%(-o #{self.id}-master), %(-n #{self.id}), %(-d))
133
126
  end
134
127
 
135
128
  true
@@ -50,6 +50,42 @@ class TestLab
50
50
  @lxc_clone ||= self.node.lxc.container("#{self.id}-master")
51
51
  end
52
52
 
53
+ # Convert to Static Container
54
+ #
55
+ # If the current container is operating as an ephemeral container, this
56
+ # will convert it back to a static container, otherwise no changes will
57
+ # occur.
58
+ #
59
+ # @return [Boolean] Returns true if successful.
60
+ def to_static
61
+ if self.lxc_clone.exists?
62
+ self.lxc.stop
63
+ self.lxc_clone.stop
64
+ self.lxc_clone.clone(%(-o #{self.lxc_clone.name}), %(-n #{self.lxc.name}))
65
+ build_lxc_config(self.lxc.config)
66
+ self.lxc_clone.destroy(%(-f))
67
+ end
68
+
69
+ true
70
+ end
71
+
72
+ # Convert to Ephemeral Container
73
+ #
74
+ # If the current container is operating as a static ocntainer, this will
75
+ # convert it to a ephemeral container, otherwise no changes will occur.
76
+ #
77
+ # @return [Boolean] Returns true if successful.
78
+ def to_ephemeral
79
+ if (self.lxc.exists? && !self.lxc_clone.exists?)
80
+ self.lxc.stop
81
+ self.lxc.clone(%(-o #{self.lxc.name}), %(-n #{self.lxc_clone.name}))
82
+ build_lxc_config(self.lxc_clone.config)
83
+ self.lxc.destroy(%(-f))
84
+ end
85
+
86
+ true
87
+ end
88
+
53
89
  # ZTK:SSH object
54
90
  #
55
91
  # Returns a *ZTK:SSH* class instance configured for this container.
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.4.9"
4
+ VERSION = "0.4.10"
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.9
4
+ version: 0.4.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -281,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  segments:
283
283
  - 0
284
- hash: 1069287922281155445
284
+ hash: -561292551195131094
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: 1069287922281155445
293
+ hash: -561292551195131094
294
294
  requirements: []
295
295
  rubyforge_project:
296
296
  rubygems_version: 1.8.25