Sha256: 5a901bca6fd1a0f60e26e684e8431009c81a62516750ac2fda9986336f0391f1

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require "log4r"
require "digest"

# Someone who's had some sleep recently is welcome to come fill in comments here...
module VagrantPlugins
  module VagrantVmwareDhcp
    module Action
      class PruneDhcp
        def initialize(app, env)
          @app    = app
          @env    = env
          @logger = Log4r::Logger.new("vagrant::plugins::vagrant-vmware-dhcp::prune_dhcp")
        end

        def call(env)
          @env = env

          if @env[:machine]
            if @env[:machine].provider_name == :vmware_fusion or @env[:machine].provider_name == :vmware_workstation
              @env[:ui].info("Pruning altered DHCP configuration")
              prune_dhcp(@env[:machine])
            end
          end

          @app.call(@env)
        end

        private

        def prune_dhcp(machine)
          # dhcp_manager = VagrantPlugins::VagrantVmwareDhcp::DhcpManager.new(@env[:ui], @logger, machine)
          dhcp_manager = get_dhcp_manager(machine)

          dhcp_manager.prune()

          dhcp_manager.reload()
        end

        def get_dhcp_manager(machine)
          if Vagrant::Util::Platform.windows?
            return VagrantPlugins::VagrantVmwareDhcp::DhcpManagerWindows.new(@env[:ui], @logger, machine)
          elsif Vagrant::Util::Platform.linux?
            return VagrantPlugins::VagrantVmwareDhcp::DhcpManagerLinux.new(@env[:ui], @logger, machine)
          elsif Vagrant::Util::Platform.darwin?
            return VagrantPlugins::VagrantVmwareDhcp::DhcpManagerDarwin.new(@env[:ui], @logger, machine)
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-vmware-dhcp-0.0.10 lib/vagrant-vmware-dhcp/action/prune_dhcp.rb
vagrant-vmware-dhcp-0.0.9 lib/vagrant-vmware-dhcp/action/prune_dhcp.rb