Class: Vagrant::Action::VM::ClearForwardedPorts
- Inherits:
-
Object
- Object
- Vagrant::Action::VM::ClearForwardedPorts
- Includes:
- ForwardPortsHelpers
- Defined in:
- lib/vagrant/action/vm/clear_forwarded_ports.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #clear ⇒ Object
-
#clear_ports ⇒ Object
Deletes existing forwarded ports.
-
#initialize(app, env) ⇒ ClearForwardedPorts
constructor
A new instance of ClearForwardedPorts.
Methods included from ForwardPortsHelpers
Constructor Details
#initialize(app, env) ⇒ ClearForwardedPorts
Returns a new instance of ClearForwardedPorts.
9 10 11 12 |
# File 'lib/vagrant/action/vm/clear_forwarded_ports.rb', line 9 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 |
# File 'lib/vagrant/action/vm/clear_forwarded_ports.rb', line 14 def call(env) @env = env clear @app.call(env) end |
#clear ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/vagrant/action/vm/clear_forwarded_ports.rb', line 20 def clear if used_ports.length > 0 @env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting") clear_ports @env["vm"].reload! end end |
#clear_ports ⇒ Object
Deletes existing forwarded ports.
29 30 31 32 33 34 35 |
# File 'lib/vagrant/action/vm/clear_forwarded_ports.rb', line 29 def clear_ports @env["vm"].vm.network_adapters.each do |na| na.nat_driver.forwarded_ports.dup.each do |fp| fp.destroy end end end |