vagrant-parallels 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7311b4684314d58491eeb5ca36fe1bb1c465b4f
4
- data.tar.gz: 1c5d0a4d8b58826bde63c5ecb438203020435aa4
3
+ metadata.gz: d7e330e0bf4f7340f2aaf9c7ed6b79d0c52cc0b8
4
+ data.tar.gz: 52857d66b61b476eab91d9b66fe4af6a2f269ec7
5
5
  SHA512:
6
- metadata.gz: 6e59b47ef130c503f23c5a1d5e16d25b632eaf88a73c5ae4cd3643af1ab882003f178c5d00e4b4f5a3c07c9d468eb89753987e03f18a8b1614ac5c14c8b228a9
7
- data.tar.gz: b739a112420e6804379d01f97791f3cd02117d8d4fe67ef510f9d347ecd438d26a0926debd43b8613928c4344ae29f71b25b624dececbf0850a55e4112814233
6
+ metadata.gz: b65c6441960be8af4f3957a416af8c49fad42749033af657f9407afa2c23bdb5abb826b9ac77b328b946d33df2994f59a00724b495f18d6629115f25c4d4e5d9
7
+ data.tar.gz: 339138fdf2352086a31b85a5803229b1d265659ffe0cba3626f8add48a168876e35814088983b8bc28340de2e16eedf7766c41e7aca84d95528262738e9fe46c
@@ -0,0 +1,15 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Cap
4
+ module HostAddress
5
+ def self.host_address(machine)
6
+
7
+ shared_iface = machine.provider.driver.read_shared_interface
8
+ return shared_iface[:ip] if shared_iface
9
+
10
+ nil
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -151,6 +151,12 @@ module VagrantPlugins
151
151
  def read_network_interfaces
152
152
  end
153
153
 
154
+ # Returns info about shared network interface.
155
+ #
156
+ # @return [Hash]
157
+ def read_shared_interface
158
+ end
159
+
154
160
  # Returns the current state of this VM.
155
161
  #
156
162
  # @return [Symbol]
@@ -91,6 +91,7 @@ module VagrantPlugins
91
91
  :read_host_only_interfaces,
92
92
  :read_mac_address,
93
93
  :read_network_interfaces,
94
+ :read_shared_interface,
94
95
  :read_settings,
95
96
  :read_state,
96
97
  :read_used_ports,
@@ -226,6 +226,10 @@ module VagrantPlugins
226
226
  end
227
227
  rescue Errno::EACCES
228
228
  raise Errors::DhcpLeasesNotAccessible, :leases_file => leases_file.to_s
229
+ rescue Errno::ENOENT
230
+ # File does not exist
231
+ # Perhaps, it is the fist start of Parallels Desktop
232
+ return nil
229
233
  end
230
234
 
231
235
  nil
@@ -307,6 +311,30 @@ module VagrantPlugins
307
311
  vm.last
308
312
  end
309
313
 
314
+ def read_shared_interface
315
+ # There should be only one Shared interface
316
+ shared_net = read_virtual_networks.detect { |net| net['Type'] == 'shared' }
317
+ return nil if !shared_net
318
+
319
+ net_info = json { execute(:prlsrvctl, 'net', 'info', shared_net['Network ID'], '--json') }
320
+ info = {
321
+ name: net_info['Bound To'],
322
+ ip: net_info['Parallels adapter']['IP address'],
323
+ netmask: net_info['Parallels adapter']['Subnet mask'],
324
+ status: "Up"
325
+ }
326
+
327
+ if net_info.key?('DHCPv4 server')
328
+ info[:dhcp] = {
329
+ ip: net_info['DHCPv4 server']['Server address'],
330
+ lower: net_info['DHCPv4 server']['IP scope start address'],
331
+ upper: net_info['DHCPv4 server']['IP scope end address']
332
+ }
333
+ end
334
+
335
+ info
336
+ end
337
+
310
338
  def read_state
311
339
  vm = json { execute('list', @uuid, '--json', retryable: true).gsub(/^INFO/, '') }
312
340
  return nil if !vm.last
@@ -226,6 +226,10 @@ module VagrantPlugins
226
226
  end
227
227
  rescue Errno::EACCES
228
228
  raise Errors::DhcpLeasesNotAccessible, :leases_file => leases_file.to_s
229
+ rescue Errno::ENOENT
230
+ # File does not exist
231
+ # Perhaps, it is the fist start of Parallels Desktop
232
+ return nil
229
233
  end
230
234
 
231
235
  nil
@@ -307,6 +311,30 @@ module VagrantPlugins
307
311
  vm.last
308
312
  end
309
313
 
314
+ def read_shared_interface
315
+ # There should be only one Shared interface
316
+ shared_net = read_virtual_networks.detect { |net| net['Type'] == 'shared' }
317
+ return nil if !shared_net
318
+
319
+ net_info = json { execute(:prlsrvctl, 'net', 'info', shared_net['Network ID'], '--json') }
320
+ info = {
321
+ name: net_info['Bound To'],
322
+ ip: net_info['Parallels adapter']['IP address'],
323
+ netmask: net_info['Parallels adapter']['Subnet mask'],
324
+ status: "Up"
325
+ }
326
+
327
+ if net_info.key?('DHCPv4 server')
328
+ info[:dhcp] = {
329
+ ip: net_info['DHCPv4 server']['Server address'],
330
+ lower: net_info['DHCPv4 server']['IP scope start address'],
331
+ upper: net_info['DHCPv4 server']['IP scope end address']
332
+ }
333
+ end
334
+
335
+ info
336
+ end
337
+
310
338
  def read_state
311
339
  vm = json { execute('list', @uuid, '--json', retryable: true) }
312
340
  return nil if !vm.last
@@ -4,35 +4,72 @@ module VagrantPlugins
4
4
  class MountParallelsSharedFolder
5
5
 
6
6
  def self.mount_parallels_shared_folder(machine, name, guestpath, options)
7
- # Expand the guest path so we can handle things like "~/vagrant"
8
7
  expanded_guest_path = machine.guest.capability(
9
8
  :shell_expand_guest_path, guestpath)
10
9
 
11
- machine.communicate.tap do |comm|
12
- # clear prior symlink
13
- if comm.test("test -L \"#{expanded_guest_path}\"", :sudo => true)
14
- comm.sudo("rm \"#{expanded_guest_path}\"")
15
- end
10
+ mount_commands = []
16
11
 
17
- # clear prior directory if exists
18
- if comm.test("test -d \"#{expanded_guest_path}\"", :sudo => true)
19
- comm.sudo("rm -Rf \"#{expanded_guest_path}\"")
20
- end
12
+ if options[:owner].is_a? Integer
13
+ mount_uid = options[:owner]
14
+ else
15
+ mount_uid = "`id -u #{options[:owner]}`"
16
+ end
17
+
18
+ if options[:group].is_a? Integer
19
+ mount_gid = options[:group]
20
+ mount_gid_old = options[:group]
21
+ else
22
+ mount_gid = "`getent group #{options[:group]} | cut -d: -f3`"
23
+ mount_gid_old = "`id -g #{options[:group]}`"
24
+ end
25
+
26
+ # First mount command uses getent to get the group
27
+ mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}"
28
+ mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
29
+ mount_commands << "mount -t prl_fs #{mount_options} #{name} #{expanded_guest_path}"
30
+
31
+ # Second mount command uses the old style `id -g`
32
+ mount_options = "-o uid=#{mount_uid},gid=#{mount_gid_old}"
33
+ mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
34
+ mount_commands << "mount -t prl_fs #{mount_options} #{name} #{expanded_guest_path}"
21
35
 
22
- # create intermediate directories if needed
23
- intermediate_dir = File.dirname(expanded_guest_path)
24
- if !comm.test("test -d \"#{intermediate_dir}\"", :sudo => true)
25
- comm.sudo("mkdir -p \"#{intermediate_dir}\"")
36
+ # Clear prior symlink if exists
37
+ machine.communicate.sudo("test -L #{expanded_guest_path} && rm -f #{expanded_guest_path}")
38
+
39
+ # Create the guest path if it doesn't exist
40
+ machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
41
+
42
+ # Attempt to mount the folder. We retry here a few times because
43
+ # it can fail early on.
44
+ attempts = 0
45
+ while true
46
+ success = true
47
+
48
+ mount_commands.each do |command|
49
+ no_such_device = false
50
+ status = machine.communicate.sudo(command, error_check: false) do |type, data|
51
+ no_such_device = true if type == :stderr && data =~ /No such device/i
52
+ end
53
+
54
+ success = status == 0 && !no_such_device
55
+ break if success
26
56
  end
27
57
 
28
- # finally make the symlink
29
- comm.sudo("ln -s \"/media/psf/#{name}\" \"#{expanded_guest_path}\"")
58
+ break if success
30
59
 
31
- # Emit an upstart event if we can
32
- if comm.test("test -x /sbin/initctl")
33
- comm.sudo(
34
- "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}")
60
+ attempts += 1
61
+ if attempts > 10
62
+ raise Vagrant::Errors::LinuxMountFailed,
63
+ command: mount_commands.join("\n")
35
64
  end
65
+
66
+ sleep 2
67
+ end
68
+
69
+ # Emit an upstart event if we can
70
+ if machine.communicate.test("test -x /sbin/initctl")
71
+ machine.communicate.sudo(
72
+ "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}")
36
73
  end
37
74
  end
38
75
  end
@@ -45,6 +45,11 @@ module VagrantPlugins
45
45
  Cap::PublicAddress
46
46
  end
47
47
 
48
+ provider_capability("parallels", "host_address") do
49
+ require_relative "cap/host_address"
50
+ Cap::HostAddress
51
+ end
52
+
48
53
  synced_folder(:parallels) do
49
54
  require File.expand_path("../synced_folder", __FILE__)
50
55
  SyncedFolder
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
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.0.2
4
+ version: 1.0.3
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-03-13 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -108,6 +108,7 @@ files:
108
108
  - lib/vagrant-parallels/action/setup_package_files.rb
109
109
  - lib/vagrant-parallels/action/suspend.rb
110
110
  - lib/vagrant-parallels/action.rb
111
+ - lib/vagrant-parallels/cap/host_address.rb
111
112
  - lib/vagrant-parallels/cap/public_address.rb
112
113
  - lib/vagrant-parallels/config.rb
113
114
  - lib/vagrant-parallels/driver/base.rb