Sha256: 82fd06863f8753b5dc79534c6413f5f1029d1d9d6ba2ecf446a8a5f652d28748

Contents?: true

Size: 1.64 KB

Versions: 16

Compression:

Stored size: 1.64 KB

Contents

class TestLab
  class Network

    module Actions

      # Create the network
      def create
        @ui.logger.debug { "Network Create: #{self.id} " }

        (self.state != :not_created) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do
          self.node.ssh.exec(%(sudo brctl addbr #{self.bridge}), :silence => true, :ignore_exit_status => true)
        end

        true
      end

      # Destroy the network
      def destroy
        @ui.logger.debug { "Network Destroy: #{self.id} " }

        (self.state == :not_created) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do
          self.node.ssh.exec(%(sudo brctl delbr #{self.bridge}), :silence => true, :ignore_exit_status => true)
        end

        true
      end

      # Start the network
      def up
        @ui.logger.debug { "Network Up: #{self.id} " }

        (self.state == :running) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
          self.node.ssh.exec(%(sudo ifconfig #{self.bridge} #{self.ip} netmask #{self.netmask} up), :silence => true, :ignore_exit_status => true)
        end

        true
      end

      # Stop the network
      def down
        @ui.logger.debug { "Network Down: #{self.id} " }

        (self.state != :running) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do
          self.node.ssh.exec(%(sudo ifconfig #{self.bridge} down), :silence => true, :ignore_exit_status => true)
        end

        true
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
testlab-0.7.4 lib/testlab/network/actions.rb
testlab-0.7.3 lib/testlab/network/actions.rb
testlab-0.7.2 lib/testlab/network/actions.rb
testlab-0.7.1 lib/testlab/network/actions.rb
testlab-0.7.0 lib/testlab/network/actions.rb
testlab-0.6.17 lib/testlab/network/actions.rb
testlab-0.6.16 lib/testlab/network/actions.rb
testlab-0.6.15 lib/testlab/network/actions.rb
testlab-0.6.14 lib/testlab/network/actions.rb
testlab-0.6.12 lib/testlab/network/actions.rb
testlab-0.6.11 lib/testlab/network/actions.rb
testlab-0.6.10 lib/testlab/network/actions.rb
testlab-0.6.9 lib/testlab/network/actions.rb
testlab-0.6.8 lib/testlab/network/actions.rb
testlab-0.6.7 lib/testlab/network/actions.rb
testlab-0.6.6 lib/testlab/network/actions.rb