From e8b46440e0a261d8d33db724ddf7959c10bcacea Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Thu, 28 May 2015 15:49:57 +0300 Subject: [PATCH] driver: Use absolute paths to Parallels binaries --- lib/vagrant-parallels/driver/base.rb | 1 + lib/vagrant-parallels/driver/pd_8.rb | 16 ++++++++-------- test/unit/support/shared/parallels_context.rb | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/vagrant-parallels/driver/base.rb b/lib/vagrant-parallels/driver/base.rb index ae3cc4c8..07477e63 100644 --- a/lib/vagrant-parallels/driver/base.rb +++ b/lib/vagrant-parallels/driver/base.rb @@ -26,6 +26,7 @@ def initialize @prlctl_path = util_path('prlctl') @prlsrvctl_path = util_path('prlsrvctl') + @prldisktool_path = util_path('prl_disk_tool') if !@prlctl_path # This means that Parallels Desktop was not found, so we raise this diff --git a/lib/vagrant-parallels/driver/pd_8.rb b/lib/vagrant-parallels/driver/pd_8.rb index 87155da5..5bc0a452 100644 --- a/lib/vagrant-parallels/driver/pd_8.rb +++ b/lib/vagrant-parallels/driver/pd_8.rb @@ -24,7 +24,7 @@ def compact(uuid) name.start_with? 'hdd' end used_drives.each_value do |drive_params| - execute('prl_disk_tool', 'compact', '--hdd', drive_params['image']) do |type, data| + execute(@prldisktool_path, 'compact', '--hdd', drive_params['image']) do |type, data| lines = data.split("\r") # The progress of the compact will be in the last line. Do a greedy # regular expression to find what we're looking for. @@ -168,9 +168,9 @@ def export(path, tpl_name) end def halt(force=false) - args = ['prlctl', 'stop', @uuid] + args = ['stop', @uuid] args << '--kill' if force - execute(*args) + execute_prlctl(*args) end def import(tpl_name) @@ -447,7 +447,7 @@ def regenerate_src_uuid end def register(pvm_file) - args = ['prlctl', 'register', pvm_file] + args = [@prlctl_path, 'register', pvm_file] 3.times do result = raw(*args) @@ -465,7 +465,7 @@ def register(pvm_file) # If we reach this point, it means that we consistently got the # failure, do a standard execute now. This will raise an # exception if it fails again. - execute(*args) + execute_prlctl(*args) end def registered?(uuid) @@ -516,7 +516,7 @@ def suspend end def unregister(uuid) - args = ['prlctl', 'unregister', uuid] + args = [@prlctl_path, 'unregister', uuid] 3.times do result = raw(*args) # Exit if everything is OK @@ -534,7 +534,7 @@ def unregister(uuid) # If we reach this point, it means that we consistently got the # failure, do a standard execute now. This will raise an # exception if it fails again. - execute(*args) + execute_prlctl(*args) end def unshare_folders(names) @@ -545,7 +545,7 @@ def unshare_folders(names) def vm_exists?(uuid) 5.times do |i| - result = raw('prlctl', 'list', uuid) + result = raw(@prlctl_path, 'list', uuid) return true if result.exit_code == 0 # Sometimes this happens. In this case, retry. If diff --git a/test/unit/support/shared/parallels_context.rb b/test/unit/support/shared/parallels_context.rb index 08d2675e..f325dc2e 100644 --- a/test/unit/support/shared/parallels_context.rb +++ b/test/unit/support/shared/parallels_context.rb @@ -34,6 +34,7 @@ def subprocess_result(options={}) # Consider that 'prlctl' and 'prlsrvctl' binaries are available allow(Vagrant::Util::Which).to receive(:which).with('prlctl').and_return('prlctl') allow(Vagrant::Util::Which).to receive(:which).with('prlsrvctl').and_return('prlsrvctl') + allow(Vagrant::Util::Which).to receive(:which).with('prl_disk_tool').and_return('prl_disk_tool') # we don't want unit tests to ever run commands on the system; so we wire # in a double to ensure any unexpected messages raise exceptions