Sha256: 5cfd0d8f47ed4996b1c673c47be6dfbdea8506f3019f0ca9271f7b8f4e229151

Contents?: true

Size: 1.35 KB

Versions: 27

Compression:

Stored size: 1.35 KB

Contents

class TestLab

  class Provisioner

    # Route Provisioner Error Class
    class RouteError < ProvisionerError; end

    # Route Provisioner Class
    #
    # @author Zachary Patten <zachary AT jovelabs DOT com>
    class Route

      def initialize(config={}, ui=nil)
        @config = (config || Hash.new)
        @ui     = (ui     || TestLab.ui)

        @config[:route] ||= Hash.new

        @ui.logger.debug { "config(#{@config.inspect})" }
      end

      # Route Provisioner Network Setup
      def on_network_setup(network)
        manage_route(:add, network)

        true
      end

      # Route Provisioner Network Teardown
      def on_network_teardown(network)
        manage_route(:del, network)

        true
      end

      def manage_route(action, network)
        command = ZTK::Command.new(:ui => @ui, :silence => true, :ignore_exit_status => true)

        case RUBY_PLATFORM
        when /darwin/ then
          action = ((action == :del) ? :delete : :add)
          command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(network.address)} #{network.node.ip} #{TestLab::Utility.netmask(network.address)}))
        when /linux/ then
          command.exec(%(sudo route #{action} -net #{TestLab::Utility.network(network.address)} netmask #{TestLab::Utility.netmask(network.address)} gw #{network.node.ip}))
        end
      end

    end

  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
testlab-0.9.1 lib/testlab/provisioners/route.rb
testlab-0.9.0 lib/testlab/provisioners/route.rb
testlab-0.8.6 lib/testlab/provisioners/route.rb
testlab-0.8.5 lib/testlab/provisioners/route.rb
testlab-0.8.4 lib/testlab/provisioners/route.rb
testlab-0.8.3 lib/testlab/provisioners/route.rb
testlab-0.8.2 lib/testlab/provisioners/route.rb
testlab-0.8.1 lib/testlab/provisioners/route.rb
testlab-0.8.0 lib/testlab/provisioners/route.rb
testlab-0.7.6 lib/testlab/provisioners/route.rb
testlab-0.7.5 lib/testlab/provisioners/route.rb
testlab-0.7.4 lib/testlab/provisioners/route.rb
testlab-0.7.3 lib/testlab/provisioners/route.rb
testlab-0.7.2 lib/testlab/provisioners/route.rb
testlab-0.7.1 lib/testlab/provisioners/route.rb
testlab-0.7.0 lib/testlab/provisioners/route.rb
testlab-0.6.17 lib/testlab/provisioners/route.rb
testlab-0.6.16 lib/testlab/provisioners/route.rb
testlab-0.6.15 lib/testlab/provisioners/route.rb
testlab-0.6.14 lib/testlab/provisioners/route.rb