Class: VagrantPlugins::ProviderKvm::Action::ClearForwardedPorts

Inherits:
Object
  • Object
show all
Includes:
Util::Commands
Defined in:
lib/vagrant-kvm/action/clear_forwarded_ports.rb

Instance Method Summary collapse

Methods included from Util::Commands

#run_command, #run_root_command

Constructor Details

#initialize(app, env) ⇒ ClearForwardedPorts

Returns a new instance of ClearForwardedPorts.



10
11
12
13
# File 'lib/vagrant-kvm/action/clear_forwarded_ports.rb', line 10

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant::kvm::action::clear_forwarded_ports")
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-kvm/action/clear_forwarded_ports.rb', line 15

def call(env)
  @env = env

  if redir_pids.any?
    env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
    redir_pids.each do |pid|
      next unless is_redir_pid?(pid)
      @logger.debug "Killing pid #{pid}"
      run_command "pkill -TERM -P #{pid}"
    end

    remove_redir_pids
  end

  @app.call env
end