Class: VagrantPlugins::ProviderLibvirt::Action::ClearForwardedPorts
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLibvirt::Action::ClearForwardedPorts
- Defined in:
- lib/vagrant-libvirt/action/forward_ports.rb
Overview
Cleans up ssh-forwarded ports on VM halt/destroy.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ClearForwardedPorts
constructor
A new instance of ClearForwardedPorts.
Constructor Details
#initialize(app, env) ⇒ ClearForwardedPorts
Returns a new instance of ClearForwardedPorts.
111 112 113 114 115 116 |
# File 'lib/vagrant-libvirt/action/forward_ports.rb', line 111 def initialize(app, env) @app = app @logger = Log4r::Logger.new( 'vagrant_libvirt::action::clear_forward_ports' ) end |
Instance Method Details
#call(env) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/vagrant-libvirt/action/forward_ports.rb', line 118 def call(env) @env = env if ssh_pids.any? env[:ui].info I18n.t( 'vagrant.actions.vm.clear_forward_ports.deleting' ) ssh_pids.each do |pid| next unless ssh_pid?(pid) @logger.debug "Killing pid #{pid}" system "kill #{pid}" end @logger.info 'Removing ssh pid files' remove_ssh_pids else @logger.info 'No ssh pids found' end @app.call env end |