Sha256: eeca4a48de715f289ca023832a3cf2ab476aac314bb930bb74b96394085ae3ad
Contents?: true
Size: 1.39 KB
Versions: 49
Compression:
Stored size: 1.39 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 include TestLab::Utility::Misc 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: Network Provision def on_network_up(network) manage_route(:add, network) true end # Route: Network Deprovision def on_network_down(network) manage_route(:del, network) true end private 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
49 entries across 49 versions & 1 rubygems