Skip to content

Commit

Permalink
Added wrapper for action 'handle_forwarded port_collisions'.
Browse files Browse the repository at this point in the history
It allows to skip calling the builtin action if port forwarding is not supported (PD < 10)
  • Loading branch information
legal90 committed Aug 21, 2014
1 parent 9625dec commit 5135ed6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/vagrant-parallels/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def self.action_simple_reboot

autoload :Boot, File.expand_path("../action/boot", __FILE__)
autoload :HandleGuestTools, File.expand_path("../action/handle_guest_tools", __FILE__)
autoload :HandleForwardedPortCollisions, File.expand_path("../action/handle_forwarded_port_collisions.rb", __FILE__)
autoload :ClearNetworkInterfaces, File.expand_path("../action/clear_network_interfaces", __FILE__)
autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__)
autoload :Customize, File.expand_path("../action/customize", __FILE__)
Expand Down
24 changes: 24 additions & 0 deletions lib/vagrant-parallels/action/handle_forwarded_port_collisions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module VagrantPlugins
module Parallels
module Action
class HandleForwardedPortCollisions < Vagrant::Action::Builtin::HandleForwardedPortCollisions
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new('vagrant_parallels::action::handle_port_collisions')
end

# This middleware just wraps the builtin action and allows to skip it if
# port forwarding is not supported for current Parallels Desktop version.
def call(env)
# Port Forwarding feature is available only with PD >= 10
if !env[:machine].provider.pd_version_satisfies?('>= 10')
return @app.call(env)
end

# Call the builtin action
super
end
end
end
end
end

0 comments on commit 5135ed6

Please sign in to comment.