lib/testlab/container/actions.rb in testlab-1.4.3 vs lib/testlab/container/actions.rb in testlab-1.4.4
- old
+ new
@@ -10,16 +10,13 @@
#
# @return [Boolean] True if successful.
def create
@ui.logger.debug { "Container Create: #{self.id}" }
- (self.node.state != :running) and return false
- (self.lxc.state != :not_created) and return false
+ (self.node.state == :running) or return false
+ (self.state == :not_created) or return false
- # If we are in ephemeral mode do not attempt to create the container.
- self.lxc_clone.exists? and return false
-
please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do
configure
self.lxc.create(*create_args)
@@ -35,18 +32,16 @@
#
# @return [Boolean] True if successful.
def destroy
@ui.logger.debug { "Container Destroy: #{self.id}" }
- (self.node.state != :running) and return false
- (self.lxc.state == :not_created) and return false
+ (self.node.state == :running) or return false
+ (self.state != :not_created) or return false
- # If we are in ephemeral mode do not attempt to destroy the container.
- self.lxc_clone.exists? and return false
-
please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do
self.lxc.destroy(%(-f))
+ self.lxc_clone.destroy(%(-f))
do_provisioner_callbacks(self, :destroy, @ui)
end
true
@@ -58,12 +53,12 @@
#
# @return [Boolean] True if successful.
def up
@ui.logger.debug { "Container Up: #{self.id}" }
- (self.node.state != :running) and return false
- (self.lxc.state == :running) and return false
+ (self.node.state == :running) or return false
+ (self.state != :running) or return false
please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
configure
# Remove any existing ARP entries for our container from the node.
@@ -104,11 +99,11 @@
#
# @return [Boolean] True if successful.
def down
@ui.logger.debug { "Container Down: #{self.id}" }
- (self.node.state != :running) and return false
- (self.lxc.state != :running) and return false
+ (self.node.state == :running) or return false
+ (self.state == :running) or return false
please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do
self.lxc.stop