vagrant-parallels 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vagrant-parallels/action/prepare_nfs_settings.rb +21 -54
- data/lib/vagrant-parallels/action.rb +4 -3
- data/lib/vagrant-parallels/driver/base.rb +2 -1
- data/lib/vagrant-parallels/driver/meta.rb +3 -2
- data/lib/vagrant-parallels/driver/pd_8.rb +6 -1
- data/lib/vagrant-parallels/errors.rb +4 -0
- data/lib/vagrant-parallels/provider.rb +1 -4
- data/lib/vagrant-parallels/version.rb +1 -1
- data/locales/en.yml +5 -0
- data/test/unit/support/shared/pd_driver_examples.rb +22 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb66fcb45443b929a94a608db1571c128d63391
|
4
|
+
data.tar.gz: ad196ab64285c216c5e7747cfd33b30475f56366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5947a49b2946e6b389daed82507446b90e0b89d71a6008a010a232aa441bbd4eeb0a5dc1fc8eee65c658dab16aa12dd765cf5a465c4accf6e16d3e2a9787af8
|
7
|
+
data.tar.gz: 47f52fbd7b6014ba913e7a3d6865f49850348d6e5df7b072b12555b49bebcf10ea13870cd23b4adb65f5c15e2484acbb02f2d6eac63569e8877de784d065cd89
|
@@ -1,7 +1,13 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require "vagrant/action/builtin/mixin_synced_folders"
|
3
|
+
|
1
4
|
module VagrantPlugins
|
2
5
|
module Parallels
|
3
6
|
module Action
|
4
7
|
class PrepareNFSSettings
|
8
|
+
include Vagrant::Action::Builtin::MixinSyncedFolders
|
9
|
+
include Vagrant::Util::Retryable
|
10
|
+
|
5
11
|
def initialize(app, env)
|
6
12
|
@app = app
|
7
13
|
@logger = Log4r::Logger.new('vagrant_parallels::action::nfs')
|
@@ -11,74 +17,35 @@ module VagrantPlugins
|
|
11
17
|
@machine = env[:machine]
|
12
18
|
@app.call(env)
|
13
19
|
|
14
|
-
|
20
|
+
opts = {
|
21
|
+
cached: !!env[:synced_folders_cached],
|
22
|
+
config: env[:synced_folders_config],
|
23
|
+
disable_usable_check: !!env[:test],
|
24
|
+
}
|
25
|
+
folders = synced_folders(env[:machine], **opts)
|
26
|
+
|
27
|
+
if folders.has_key?(:nfs)
|
15
28
|
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
16
29
|
add_ips_to_env!(env)
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
20
|
-
# We're using NFS if we have any synced folder with NFS configured. If
|
21
|
-
# we are not using NFS we don't need to do the extra work to
|
22
|
-
# populate these fields in the environment.
|
23
|
-
def using_nfs?(env)
|
24
|
-
env && env.synced_folders.any? { |_, opts| opts[:type] == :nfs }
|
25
|
-
end
|
26
|
-
|
27
33
|
# Extracts the proper host and guest IPs for NFS mounts and stores them
|
28
34
|
# in the environment for the SyncedFolder action to use them in
|
29
35
|
# mounting.
|
30
36
|
#
|
31
37
|
# The ! indicates that this method modifies its argument.
|
32
38
|
def add_ips_to_env!(env)
|
33
|
-
host_ip
|
34
|
-
|
39
|
+
host_ip = @machine.provider.driver.read_shared_interface[:ip]
|
40
|
+
guest_ip = @machine.provider.driver.read_guest_ip
|
35
41
|
|
36
|
-
|
42
|
+
# If we couldn't determine either guest's or host's IP, then
|
43
|
+
# it is probably a bug. Display an appropriate error message.
|
44
|
+
raise Vagrant::Errors::NFSNoHostIP if !host_ip
|
45
|
+
raise Vagrant::Errors::NFSNoGuestIP if !guest_ip
|
37
46
|
|
38
47
|
env[:nfs_host_ip] = host_ip
|
39
|
-
env[:nfs_machine_ip] =
|
40
|
-
end
|
41
|
-
|
42
|
-
# Finds first host only network adapter and returns its IP address
|
43
|
-
#
|
44
|
-
# @return [String] ip address of found host-only adapter
|
45
|
-
def find_host_only_adapter
|
46
|
-
host_only_all = @machine.provider.driver.read_host_only_interfaces
|
47
|
-
host_only_used = @machine.provider.driver.read_network_interfaces.
|
48
|
-
select { |_, opts| opts[:type] == :hostonly }
|
49
|
-
|
50
|
-
host_only_used.each do |_, opts|
|
51
|
-
host_only_all.each do |interface|
|
52
|
-
if @machine.provider.pd_version_satisfies?('>= 10')
|
53
|
-
name_matched = interface[:name] == opts[:hostonly]
|
54
|
-
else
|
55
|
-
name_matched = interface[:bound_to] == opts[:hostonly]
|
56
|
-
end
|
57
|
-
|
58
|
-
return interface[:ip] if name_matched
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
nil
|
63
|
-
end
|
64
|
-
|
65
|
-
# Returns the IP address of the guest by looking at the first
|
66
|
-
# enabled host only network.
|
67
|
-
#
|
68
|
-
# @return [String] ip address of adapter in guest
|
69
|
-
def read_machine_ip
|
70
|
-
ips = []
|
71
|
-
@machine.config.vm.networks.each do |type, options|
|
72
|
-
if type == :private_network && options[:ip].is_a?(String)
|
73
|
-
ips << options[:ip]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
if ips.empty?
|
78
|
-
raise Vagrant::Errors::NFSNoGuestIP
|
79
|
-
end
|
80
|
-
|
81
|
-
ips
|
48
|
+
env[:nfs_machine_ip] = guest_ip
|
82
49
|
end
|
83
50
|
end
|
84
51
|
end
|
@@ -304,8 +304,9 @@ module VagrantPlugins
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
# This
|
308
|
-
#
|
307
|
+
# This is the action that is called to sync folders to a running machine
|
308
|
+
# without a reboot. It is used by the docker provider to link synced
|
309
|
+
# folders on the host machine as volumes into the docker containers.
|
309
310
|
def self.action_sync_folders
|
310
311
|
Vagrant::Action::Builder.new.tap do |b|
|
311
312
|
b.use ConfigValidate
|
@@ -320,7 +321,7 @@ module VagrantPlugins
|
|
320
321
|
b2.use Message, I18n.t("vagrant.commands.common.vm_not_running")
|
321
322
|
next
|
322
323
|
end
|
323
|
-
|
324
|
+
b2.use PrepareNFSValidIds
|
324
325
|
b2.use SyncedFolders
|
325
326
|
b2.use PrepareNFSSettings
|
326
327
|
end
|
@@ -177,7 +177,8 @@ module VagrantPlugins
|
|
177
177
|
def read_state
|
178
178
|
end
|
179
179
|
|
180
|
-
# Returns a value of specified VM option
|
180
|
+
# Returns a value of specified VM option. Raises an exception if value
|
181
|
+
# is not available
|
181
182
|
#
|
182
183
|
# @param [String] option Name of option (See all: `prlctl list -L`)
|
183
184
|
# @param [String] uuid Virtual machine UUID
|
@@ -32,8 +32,7 @@ module VagrantPlugins
|
|
32
32
|
# specific driver to instantiate.
|
33
33
|
begin
|
34
34
|
@version = read_version || ""
|
35
|
-
rescue Vagrant::Errors::CommandUnavailable
|
36
|
-
Vagrant::Errors::CommandUnavailableWindows
|
35
|
+
rescue Vagrant::Errors::CommandUnavailable
|
37
36
|
# This means that Parallels Desktop was not found, so we raise this
|
38
37
|
# error here.
|
39
38
|
raise VagrantPlugins::Parallels::Errors::ParallelsNotDetected
|
@@ -89,6 +88,7 @@ module VagrantPlugins
|
|
89
88
|
:import,
|
90
89
|
:read_bridged_interfaces,
|
91
90
|
:read_forwarded_ports,
|
91
|
+
:read_guest_ip,
|
92
92
|
:read_guest_tools_state,
|
93
93
|
:read_guest_tools_iso_path,
|
94
94
|
:read_host_only_interfaces,
|
@@ -101,6 +101,7 @@ module VagrantPlugins
|
|
101
101
|
:read_state,
|
102
102
|
:read_used_ports,
|
103
103
|
:read_virtual_networks,
|
104
|
+
:read_vm_option,
|
104
105
|
:read_vms,
|
105
106
|
:read_vms_info,
|
106
107
|
:read_vms_paths,
|
@@ -392,7 +392,12 @@ module VagrantPlugins
|
|
392
392
|
end
|
393
393
|
|
394
394
|
def read_vm_option(option, uuid=@uuid)
|
395
|
-
execute_prlctl('list', uuid,'--no-header', '-o', option)
|
395
|
+
out = execute_prlctl('list', uuid,'--no-header', '-o', option).strip
|
396
|
+
if out.empty?
|
397
|
+
raise Errors::ParallelsVMOptionNotFound, vm_option: option
|
398
|
+
end
|
399
|
+
|
400
|
+
out
|
396
401
|
end
|
397
402
|
|
398
403
|
def read_vms
|
@@ -51,6 +51,10 @@ module VagrantPlugins
|
|
51
51
|
error_key(:parallels_tpl_name_not_found)
|
52
52
|
end
|
53
53
|
|
54
|
+
class ParallelsVMOptionNotFound < VagrantParallelsError
|
55
|
+
error_key(:parallels_vm_option_not_found)
|
56
|
+
end
|
57
|
+
|
54
58
|
class VMImportFailure < VagrantParallelsError
|
55
59
|
error_key(:vm_import_failure)
|
56
60
|
end
|
@@ -15,10 +15,7 @@ module VagrantPlugins
|
|
15
15
|
# version and all that, which checks for Parallels Desktop being present
|
16
16
|
Driver::Meta.new
|
17
17
|
true
|
18
|
-
rescue
|
19
|
-
raise if raise_error
|
20
|
-
return false
|
21
|
-
rescue VagrantPlugins::Parallels::Errors::ParallelsNotDetected
|
18
|
+
rescue Errors::VagrantParallelsError
|
22
19
|
raise if raise_error
|
23
20
|
return false
|
24
21
|
end
|
data/locales/en.yml
CHANGED
@@ -70,6 +70,11 @@ en:
|
|
70
70
|
the box you're using is not corrupted and try again.
|
71
71
|
|
72
72
|
Template config path: "%{config_path}"
|
73
|
+
|
74
|
+
parallels_vm_option_not_found: |-
|
75
|
+
Could not find a required option of Parallels Desktop virtual machine:
|
76
|
+
%{vm_option}
|
77
|
+
This is an internal error that should be reported as a bug.
|
73
78
|
vm_import_failure: |-
|
74
79
|
The VM import failed! Please verify that the box you're using is not
|
75
80
|
corrupted and try again.
|
@@ -201,6 +201,27 @@ shared_examples "parallels desktop driver" do |options|
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
+
describe 'read_vm_option' do
|
205
|
+
it 'returns stripped value' do
|
206
|
+
subprocess.stub(:execute).
|
207
|
+
with('prlctl', 'list', uuid, '--no-header', '-o', an_instance_of(String),
|
208
|
+
an_instance_of(Hash)).
|
209
|
+
and_return(subprocess_result(stdout: "opt_val \n"))
|
210
|
+
|
211
|
+
subject.read_vm_option('supported_option').should == 'opt_val'
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'raises an exception in option is not available' do
|
215
|
+
subprocess.stub(:execute).
|
216
|
+
with('prlctl', 'list', uuid, '--no-header', '-o', an_instance_of(String),
|
217
|
+
an_instance_of(Hash)).
|
218
|
+
and_return(subprocess_result(stdout: " \n"))
|
219
|
+
|
220
|
+
expect { subject.read_vm_option('invalid_option') }.
|
221
|
+
to raise_error(VagrantPlugins::Parallels::Errors::ParallelsVMOptionNotFound)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
204
225
|
describe "read_vms" do
|
205
226
|
it "returns the list of all registered VMs and templates" do
|
206
227
|
subject.read_vms.should be_kind_of(Hash)
|
@@ -295,7 +316,7 @@ shared_examples "parallels desktop driver" do |options|
|
|
295
316
|
subject.version.should match(/^#{parallels_version}.\d+\.\d+$/)
|
296
317
|
end
|
297
318
|
|
298
|
-
it "
|
319
|
+
it "raises ParallelsInvalidVersion exception for unsupported version" do
|
299
320
|
subprocess.should_receive(:execute).
|
300
321
|
with("prlctl", "--version", an_instance_of(Hash)).
|
301
322
|
and_return(subprocess_result(stdout: "prlctl version 7.0.12345"))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-parallels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikhail Zholobov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|