class TestLab class Network module Actions # Create the network def create @ui.logger.debug { "Network Create: #{self.id} " } self.node.alive? 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 < @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 brctl delbr #{self.bridge} EOF do_provisioner_callbacks(self, :destroy, @ui) end true end # Start the network def up @ui.logger.debug { "Network Up: #{self.id} " } self.node.alive? 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 EOF do_provisioner_callbacks(self, :up, @ui) end true end # Stop the network def down @ui.logger.debug { "Network Down: #{self.id} " } self.node.alive? 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 EOF do_provisioner_callbacks(self, :down, @ui) end true end end end end