Skip to content

Commit

Permalink
Release v1.2.1
Browse files Browse the repository at this point in the history
* master:
  Added wrapper for action 'handle_forwarded port_collisions'.
  Reboot the VM right after Parallels Tools installation/upgrade [GH-133]
  actions: Added 'post-comm' customization step
  errors: Added custom 'linux_mount_failed' message
  • Loading branch information
legal90 committed Aug 21, 2014
2 parents fe2275b + 5135ed6 commit a88de4e
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 3 deletions.
20 changes: 20 additions & 0 deletions lib/vagrant-parallels/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def self.action_boot
b.use Boot
b.use Customize, "post-boot"
b.use WaitForCommunicator, [:starting, :running]
b.use Customize, "post-comm"
b.use HandleGuestTools
end
end
Expand Down Expand Up @@ -285,8 +286,27 @@ def self.action_up
end
end

# This action simply reboots the VM. It is executed right after
# Parallels Tools installation or upgrade.
def self.action_simple_reboot
Vagrant::Action::Builder.new.tap do |b|
b.use Call, GracefulHalt, :stopped, :running do |env2, b2|
if !env2[:result]
b2.use ForcedHalt
end
end

b.use Customize, "pre-boot"
b.use Boot
b.use Customize, "post-boot"
b.use WaitForCommunicator, [:starting, :running]
b.use Customize, "post-comm"
end
end

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
5 changes: 5 additions & 0 deletions lib/vagrant-parallels/action/handle_guest_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def call(env)
if @machine.guest.capability?(:install_parallels_tools)
env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.installing"))
@machine.guest.capability(:install_parallels_tools)

# The VM should be rebooted to enable kernel modules
# bundled with Parallels Tools.
env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.rebooting"))
@machine.action(:simple_reboot)
else
env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.cant_install"))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def finalize!

def validate(machine)
errors = _detected_errors
valid_events = ["pre-import", "pre-boot", "post-boot"]
valid_events = ["pre-import", "pre-boot", "post-boot", "post-comm"]
@customizations.each do |event, _|
if !valid_events.include?(event)
errors << I18n.t("vagrant_parallels.config.invalid_event",
Expand Down
4 changes: 4 additions & 0 deletions lib/vagrant-parallels/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class DhcpLeasesNotAccessible < VagrantParallelsError
error_key(:dhcp_leases_file_not_accessible)
end

class LinuxMountFailed < VagrantParallelsError
error_key(:linux_mount_failed)
end

class MacOSXRequired < VagrantParallelsError
error_key(:mac_os_x_required)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def self.mount_parallels_shared_folder(machine, name, guestpath, options)

attempts += 1
if attempts > 10
raise Vagrant::Errors::LinuxMountFailed,
raise VagrantPlugins::Parallels::Errors::LinuxMountFailed,
command: mount_commands.join("\n")
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Parallels
VERSION = "1.2.0"
VERSION = "1.2.1"
end
end
12 changes: 12 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ en:
Command: %{command}
Stderr: %{stderr}
linux_mount_failed: |-
Failed to mount folders in Linux guest. This is usually because
the "prl_fs" file system is not available. Please verify that
Parallels Tools are properly installed in the guest and
can work properly. If so, the VM reboot can solve a problem.
The command attempted was:
%{command}
mac_os_x_required: |-
Parallels provider works only on OS X (Mac OS X) systems.
parallels_install_incomplete: |-
Expand Down Expand Up @@ -118,6 +128,8 @@ en:
If SSH fails or shared folders are not working on this machine,
please install Parallels Tools within the virtual machine and
reload your VM.
rebooting: |-
Parallels Tools have been installed. Rebooting the VM...
outdated: |-
Parallels Tools installed on this VM are outdated! In most cases
this is fine but in rare cases it can cause things such as shared
Expand Down

0 comments on commit a88de4e

Please sign in to comment.