vagrant-parallels 1.0.4 → 1.0.5

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: 3bb0c73a32406073cd7cbbef316c2948a66d189a
4
- data.tar.gz: c1570c322c010f90bca25f4c5ebfa637e92a78fe
3
+ metadata.gz: eb12258f3633c2410bb455924faeb91121eab63e
4
+ data.tar.gz: 7c71d64c033ba1b47194953043e079da0f6e45d5
5
5
  SHA512:
6
- metadata.gz: 522c879332300104120ef72300f8f28ced3fcd00e9289f8d9598850fad0c69b98b519e049a4893bd9e5c9702d3cbc30717845d415873cb9fb32083f6045192a0
7
- data.tar.gz: 2a7b8f00fe6754fb82e3a8d80632756a335b729506f32a84b62148b1b1b3ef3716db7013dffcf031f60a5b4fb0907f0d0fc29900c311c712a07acf2ada975c3d
6
+ metadata.gz: f0b684db6250f2bd02b1be5e934d8d8365ae57504ba8448f60ac81fd629ffed3f14b4e26159c44d6042630b349133b430340ad82124c3e8478900bcbca6106a8
7
+ data.tar.gz: e659d2ca5ff2c560db321a1a1b32f0bf6f70bbe6bc870a0700b82cccf1e279bf9e9b421a49001f4135fc126141763d6b77a326c99f616da5faf0b86c70570eac
@@ -0,0 +1,55 @@
1
+ require "log4r"
2
+ require 'vagrant/util/platform'
3
+
4
+ module VagrantPlugins
5
+ module Parallels
6
+ module Action
7
+ class ForcePrlFsMount
8
+ # This middleware forces the prl_fs mount after the Resume, because
9
+ # there is bug in Linux guests - custom shared folders are missed after
10
+ # the resume [GH-102]
11
+ include Vagrant::Action::Builtin::MixinSyncedFolders
12
+
13
+ def initialize(app, env)
14
+ @app = app
15
+ @logger = Log4r::Logger.new("vagrant::plugins::parallels::force_prl_fs_mount")
16
+ end
17
+
18
+ def call(env)
19
+ # Only for Linux guests!
20
+ if env[:machine].communicate.test("uname -s | grep 'Linux'")
21
+ folders = synced_folders(env[:machine])[:parallels]
22
+
23
+ # Go through each folder and make sure to create it if
24
+ # it does not exist on host
25
+ folders.each do |id, data|
26
+ data[:hostpath] = File.expand_path(data[:hostpath], env[:root_path])
27
+
28
+ # Create the hostpath if it doesn't exist and we've been told to
29
+ if !File.directory?(data[:hostpath]) && data[:create]
30
+ @logger.info("Creating shared folder host directory: #{data[:hostpath]}")
31
+ begin
32
+ Pathname.new(data[:hostpath]).mkpath
33
+ rescue Errno::EACCES
34
+ raise Vagrant::Errors::SharedFolderCreateFailed,
35
+ path: data[:hostpath]
36
+ end
37
+ end
38
+
39
+ if File.directory?(data[:hostpath])
40
+ data[:hostpath] = File.realpath(data[:hostpath])
41
+ data[:hostpath] = Vagrant::Util::Platform.fs_real_path(data[:hostpath]).to_s
42
+ end
43
+ end
44
+
45
+ opts = nil
46
+ instance = VagrantPlugins::Parallels::SyncedFolder.new
47
+ instance.enable(env[:machine], folders, opts)
48
+ end
49
+
50
+ @app.call(env)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -168,6 +168,7 @@ module VagrantPlugins
168
168
  b2.use EnvSet, :port_collision_repair => false
169
169
  b2.use Resume
170
170
  b2.use WaitForCommunicator, [:resuming, :running]
171
+ b2.use ForcePrlFsMount
171
172
  else
172
173
  b2.use MessageNotCreated
173
174
  end
@@ -283,6 +284,7 @@ module VagrantPlugins
283
284
  autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__)
284
285
  autoload :Export, File.expand_path("../action/export", __FILE__)
285
286
  autoload :ForcedHalt, File.expand_path("../action/forced_halt", __FILE__)
287
+ autoload :ForcePrlFsMount, File.expand_path("../action/force_prl_fs_mount", __FILE__)
286
288
  autoload :Import, File.expand_path("../action/import", __FILE__)
287
289
  autoload :IsSuspended, File.expand_path("../action/is_suspended", __FILE__)
288
290
  autoload :IsRunning, File.expand_path("../action/is_running", __FILE__)
@@ -41,6 +41,10 @@ module VagrantPlugins
41
41
  def clear_shared_folders
42
42
  end
43
43
 
44
+ # Compacts all disk drives of virtual machine
45
+ def compact
46
+ end
47
+
44
48
  # Creates a host only network with the given options.
45
49
  #
46
50
  # @param [Hash] options Options to create the host only network.
@@ -100,7 +104,7 @@ module VagrantPlugins
100
104
  end
101
105
 
102
106
  # Halts the virtual machine (pulls the plug).
103
- def halt
107
+ def halt(force)
104
108
  end
105
109
 
106
110
  # Imports the VM by cloning from registered template.
@@ -157,6 +161,13 @@ module VagrantPlugins
157
161
  def read_shared_interface
158
162
  end
159
163
 
164
+ # Returns a list of shared folders in format:
165
+ # { id => hostpath, ... }
166
+ #
167
+ # @return [Hash]
168
+ def read_shared_folders
169
+ end
170
+
160
171
  # Returns the current state of this VM.
161
172
  #
162
173
  # @return [Symbol]
@@ -170,9 +181,13 @@ module VagrantPlugins
170
181
  def read_vms
171
182
  end
172
183
 
184
+ # Registers the virtual machine
185
+ def register(pvm_file)
186
+ end
187
+
173
188
  # Resumes the virtual machine.
174
189
  #
175
- def resume(mac)
190
+ def resume
176
191
  end
177
192
 
178
193
  # Sets the MAC address of the first network adapter.
@@ -181,7 +196,7 @@ module VagrantPlugins
181
196
  def set_mac_address(mac)
182
197
  end
183
198
 
184
- # Sets the VM name.
199
+ # Sets the name of the virtual machine.
185
200
  #
186
201
  # @param [String] name New VM name.
187
202
  def set_name(name)
@@ -92,6 +92,7 @@ module VagrantPlugins
92
92
  :read_mac_address,
93
93
  :read_network_interfaces,
94
94
  :read_shared_interface,
95
+ :read_shared_folders,
95
96
  :read_settings,
96
97
  :read_state,
97
98
  :read_used_ports,
@@ -32,10 +32,9 @@ module VagrantPlugins
32
32
  end
33
33
 
34
34
  def clear_shared_folders
35
- shf = read_settings.fetch("Host Shared Folders", {}).keys
36
- shf.delete("enabled")
37
- shf.each do |folder|
38
- execute("set", @uuid, "--shf-host-del", folder)
35
+ share_ids = read_shared_folders.keys
36
+ share_ids.each do |id|
37
+ execute("set", @uuid, "--shf-host-del", id)
39
38
  end
40
39
  end
41
40
 
@@ -335,6 +334,16 @@ module VagrantPlugins
335
334
  info
336
335
  end
337
336
 
337
+ def read_shared_folders
338
+ shf_info = read_settings.fetch("Host Shared Folders", {})
339
+ list = {}
340
+ shf_info.delete_if {|k,v| k == "enabled"}.each do |id, data|
341
+ list[id] = data.fetch("path")
342
+ end
343
+
344
+ list
345
+ end
346
+
338
347
  def read_state
339
348
  vm = json { execute('list', @uuid, '--json', retryable: true).gsub(/^INFO/, '') }
340
349
  return nil if !vm.last
@@ -32,10 +32,9 @@ module VagrantPlugins
32
32
  end
33
33
 
34
34
  def clear_shared_folders
35
- shf = read_settings.fetch("Host Shared Folders", {}).keys
36
- shf.delete("enabled")
37
- shf.each do |folder|
38
- execute("set", @uuid, "--shf-host-del", folder)
35
+ share_ids = read_shared_folders.keys
36
+ share_ids.each do |id|
37
+ execute("set", @uuid, "--shf-host-del", id)
39
38
  end
40
39
  end
41
40
 
@@ -335,6 +334,16 @@ module VagrantPlugins
335
334
  info
336
335
  end
337
336
 
337
+ def read_shared_folders
338
+ shf_info = read_settings.fetch("Host Shared Folders", {})
339
+ list = {}
340
+ shf_info.delete_if {|k,v| k == "enabled"}.each do |id, data|
341
+ list[id] = data.fetch("path")
342
+ end
343
+
344
+ list
345
+ end
346
+
338
347
  def read_state
339
348
  vm = json { execute('list', @uuid, '--json', retryable: true) }
340
349
  return nil if !vm.last
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  module Parallels
5
5
  class SyncedFolder < Vagrant.plugin("2", :synced_folder)
6
6
  def usable?(machine)
7
- # These synced folders only work if the provider if VirtualBox
7
+ # These synced folders only work if the provider is Parallels
8
8
  machine.provider_name == :parallels
9
9
  end
10
10
 
@@ -21,6 +21,9 @@ module VagrantPlugins
21
21
  }
22
22
  end
23
23
 
24
+ # We should prepare only folders with unique hostpath values.
25
+ # Anyway, duplicates will be mounted later.
26
+ defs.uniq! { |d| d[:hostpath] }
24
27
  driver(machine).share_folders(defs)
25
28
  end
26
29
 
@@ -35,10 +38,16 @@ module VagrantPlugins
35
38
  end
36
39
  end
37
40
 
41
+ shf_config = driver(machine).read_shared_folders
42
+
38
43
  # Go through each folder and mount
39
44
  machine.ui.output(I18n.t("vagrant.actions.vm.share_folders.mounting"))
40
- folders.each do |id, data|
41
- if data[:guestpath]
45
+ folders.each do |_ , data|
46
+ # Parallels specific: get id from the VM setting
47
+ # It allows to mount one host folder more then one time [GH-105]
48
+ id = shf_config.key(data[:hostpath])
49
+
50
+ if data[:guestpath] and id
42
51
  id = Pathname.new(id).to_s.split('/').drop_while{|i| i.empty?}.join('_')
43
52
 
44
53
  # Guest path specified, so mount the folder to specified point
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
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.4
4
+ version: 1.0.5
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-20 00:00:00.000000000 Z
12
+ date: 2014-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -90,6 +90,7 @@ files:
90
90
  - lib/vagrant-parallels/action/destroy.rb
91
91
  - lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb
92
92
  - lib/vagrant-parallels/action/export.rb
93
+ - lib/vagrant-parallels/action/force_prl_fs_mount.rb
93
94
  - lib/vagrant-parallels/action/forced_halt.rb
94
95
  - lib/vagrant-parallels/action/import.rb
95
96
  - lib/vagrant-parallels/action/is_running.rb