lib/testlab/network/actions.rb in testlab-1.4.3 vs lib/testlab/network/actions.rb in testlab-1.4.4

- old
+ new

@@ -5,20 +5,20 @@ # Create the network def create @ui.logger.debug { "Network Create: #{self.id} " } - (self.node.state != :running) and return false - (self.state != :not_created) and return false + (self.node.state == :running) or return false + (self.state == :not_created) or return false please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do self.node.bootstrap(<<-EOF, :ignore_exit_status => true) set -x grep '#{def_tag}' /etc/network/interfaces && exit 0 cat <<EOI | tee -a /etc/network/interfaces #{def_tag} -auto br0 +auto #{self.bridge} iface #{self.bridge} inet static bridge_ports none bridge_stp off bridge_fd 0 address #{self.ip} @@ -39,12 +39,12 @@ # Destroy the network def destroy @ui.logger.debug { "Network Destroy: #{self.id} " } - (self.node.state != :running) and return false - (self.state == :not_created) and return false + (self.node.state == :running) or return false + (self.state != :not_created) or return false please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do self.node.bootstrap(<<-EOF, :ignore_exit_status => true) set -x sed -i '/#{def_tag}/,/#{end_tag}/d' /etc/network/interfaces @@ -59,12 +59,12 @@ # Start the network def up @ui.logger.debug { "Network Up: #{self.id} " } - (self.node.state != :running) and return false - # (self.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 self.node.bootstrap(<<-EOF, :ignore_exit_status => true) set -x ifconfig #{self.bridge} #{self.ip} netmask #{self.netmask} broadcast #{self.broadcast} up @@ -78,11 +78,11 @@ # Stop the network def down @ui.logger.debug { "Network Down: #{self.id} " } - (self.node.state != :running) and return false - # (self.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.node.bootstrap(<<-EOF, :ignore_exit_status => true) set -x ifconfig #{self.bridge} down