lib/testlab/container/lifecycle.rb in testlab-0.7.6 vs lib/testlab/container/lifecycle.rb in testlab-0.8.0
- old
+ new
@@ -11,10 +11,13 @@
#
# @return [Boolean] True if successful.
def setup
@ui.logger.debug { "Container Setup: #{self.id} " }
+ (self.node.state != :running) and return false
+ (self.lxc.state == :not_created) and return false
+
please_wait(:ui => @ui, :message => format_object_action(self, 'Setup', :green)) do
self.container_provisioners.each do |provisioner|
@ui.logger.info { ">>>>> CONTAINER PROVISIONER SETUP: #{provisioner} <<<<<" }
p = provisioner.new(self.config, @ui)
@@ -34,10 +37,11 @@
#
# @return [Boolean] True if successful.
def teardown
@ui.logger.debug { "Container Teardown: #{self.id} " }
+ (self.node.state != :running) and return false
(self.lxc.state == :not_created) and return false
please_wait(:ui => @ui, :message => format_object_action(self, 'Teardown', :red)) do
self.container_provisioners.each do |provisioner|
@@ -54,9 +58,18 @@
# Build the container
def build
self.create
self.up
self.setup
+
+ true
+ end
+
+ # Demolish the container
+ def demolish
+ self.teardown
+ self.down
+ self.destroy
true
end
# Returns all defined provisioners for this container's networks and the container iteself.