vagrant-parallels 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/vagrant-parallels/action/box_register.rb +26 -8
- data/lib/vagrant-parallels/action/box_unregister.rb +33 -1
- data/lib/vagrant-parallels/action/import.rb +16 -23
- data/lib/vagrant-parallels/action/network.rb +1 -1
- data/lib/vagrant-parallels/driver/base.rb +5 -38
- data/lib/vagrant-parallels/version.rb +1 -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: 8c838025184a0d6acdfbb7c6434427e3730fe16f
|
4
|
+
data.tar.gz: 88541ff940262fefdf1602ab2753ad73c5c8ce8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd23145472fdfb85da1abbea1d89fdf3d673ad4f74853bdfe9afe52c59a62a89245102ad6b806dd123ef266f293ed3afac4f739985ef0489081890f461223854
|
7
|
+
data.tar.gz: 272b8cbf4d71909b58f3bce0f33b6a3b3f77f07da3a3c5e355eea2244bd1028ca42310bf7c9db55f3d0491c14875d7517e59f347d6ac997bebe11d7ebdf36e21
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 1.6.1 (January 13, 2016)
|
2
|
+
|
3
|
+
BUG FIXES:
|
4
|
+
- action/import: Fix `regenerate_src_uuid` option behavior in parallel run
|
5
|
+
[[GH-241](https://github.com/Parallels/vagrant-parallels/pull/241)]
|
6
|
+
- action/box_unregister: Use temporary lock file to prevent early unregister
|
7
|
+
in parallel run [[GH-244](https://github.com/Parallels/vagrant-parallels/pull/244)]
|
8
|
+
- action/network: Fix detection of the next virtual network ID [[GH-245](https://github.com/Parallels/vagrant-parallels/pull/245)]
|
9
|
+
|
10
|
+
|
1
11
|
## 1.6.0 (December 24, 2015)
|
2
12
|
|
3
13
|
BREAKING CHANGES:
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'log4r'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
@@ -58,13 +59,35 @@ module VagrantPlugins
|
|
58
59
|
config: tpl_config
|
59
60
|
end
|
60
61
|
|
61
|
-
id
|
62
|
+
id.delete('{}')
|
63
|
+
end
|
64
|
+
|
65
|
+
def lease_box_lock(env)
|
66
|
+
lease_file = env[:machine].box.directory.join('box_lease_count')
|
67
|
+
|
68
|
+
# If the temporary file, verify it is not too old. If its older than
|
69
|
+
# 1 hour, delete it first because previous run may be failed.
|
70
|
+
if lease_file.file? && lease_file.mtime.to_i < Time.now.to_i - 60 * 60
|
71
|
+
lease_file.delete
|
72
|
+
end
|
73
|
+
|
74
|
+
# Increment a counter in the file. Create the file if it doesn't exist
|
75
|
+
FileUtils.touch(lease_file)
|
76
|
+
File.open(lease_file ,'r+') do |file|
|
77
|
+
num = file.gets.to_i
|
78
|
+
file.rewind
|
79
|
+
file.puts num.next
|
80
|
+
file.fsync
|
81
|
+
file.flush
|
82
|
+
end
|
62
83
|
end
|
63
84
|
|
64
85
|
def register_box(env)
|
65
|
-
|
86
|
+
# Increment the lock counter in the temporary lease file
|
87
|
+
lease_box_lock(env)
|
66
88
|
|
67
|
-
# Read the
|
89
|
+
# Read the box ID if we have it in the file.
|
90
|
+
box_id_file = env[:machine].box.directory.join('box_id')
|
68
91
|
env[:clone_id] = box_id_file.read.chomp if box_id_file.file?
|
69
92
|
|
70
93
|
# If we have the ID and the VM exists already, then we
|
@@ -84,11 +107,6 @@ module VagrantPlugins
|
|
84
107
|
# We need the box ID to be the same for all parallel runs
|
85
108
|
options = ['--preserve-uuid']
|
86
109
|
|
87
|
-
if env[:machine].provider_config.regen_src_uuid \
|
88
|
-
&& env[:machine].provider.pd_version_satisfies?('>= 10.1.2')
|
89
|
-
options << '--regenerate-src-uuid'
|
90
|
-
end
|
91
|
-
|
92
110
|
# Register the box VM image
|
93
111
|
env[:machine].provider.driver.register(pvm, options)
|
94
112
|
env[:clone_id] = box_id(env, pvm)
|
@@ -4,6 +4,8 @@ module VagrantPlugins
|
|
4
4
|
module Parallels
|
5
5
|
module Action
|
6
6
|
class BoxUnregister
|
7
|
+
@@lock = Mutex.new
|
8
|
+
|
7
9
|
def initialize(app, env)
|
8
10
|
@app = app
|
9
11
|
@logger = Log4r::Logger.new('vagrant_parallels::action::box_unregister')
|
@@ -15,7 +17,12 @@ module VagrantPlugins
|
|
15
17
|
return @app.call(env)
|
16
18
|
end
|
17
19
|
|
18
|
-
|
20
|
+
@@lock.synchronize do
|
21
|
+
lock_key = Digest::MD5.hexdigest(env[:machine].box.name)
|
22
|
+
env[:machine].env.lock(lock_key, retry: true) do
|
23
|
+
unregister_box(env)
|
24
|
+
end
|
25
|
+
end
|
19
26
|
|
20
27
|
# If we got interrupted, then the import could have been
|
21
28
|
# interrupted and its not a big deal. Just return out.
|
@@ -31,7 +38,32 @@ module VagrantPlugins
|
|
31
38
|
|
32
39
|
private
|
33
40
|
|
41
|
+
def release_box_lock(lease_file)
|
42
|
+
return if !lease_file.file?
|
43
|
+
|
44
|
+
# Decrement the counter in the lease file
|
45
|
+
File.open(lease_file,'r+') do |file|
|
46
|
+
num = file.gets.to_i
|
47
|
+
file.rewind
|
48
|
+
file.puts(num - 1)
|
49
|
+
file.fsync
|
50
|
+
file.flush
|
51
|
+
end
|
52
|
+
|
53
|
+
# Delete the lease file if we are the last who need this box.
|
54
|
+
# Then the box image will be unregistered.
|
55
|
+
lease_file.delete if lease_file.read.chomp.to_i <= 1
|
56
|
+
end
|
57
|
+
|
34
58
|
def unregister_box(env)
|
59
|
+
# Release the box lock
|
60
|
+
lease_file = env[:machine].box.directory.join('box_lease_count')
|
61
|
+
release_box_lock(lease_file)
|
62
|
+
|
63
|
+
# Do not unregister the box image if the temporary lease file exists
|
64
|
+
# Most likely it is cloning to another Vagrant env (in parallel run)
|
65
|
+
return if lease_file.file?
|
66
|
+
|
35
67
|
if env[:clone_id] && env[:machine].provider.driver.vm_exists?(env[:clone_id])
|
36
68
|
env[:ui].info I18n.t('vagrant_parallels.actions.vm.box.unregister')
|
37
69
|
env[:machine].provider.driver.unregister(env[:clone_id])
|
@@ -14,6 +14,8 @@ module VagrantPlugins
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def call(env)
|
17
|
+
options = {}
|
18
|
+
|
17
19
|
# Disable requiring password for register and clone actions [GH-67].
|
18
20
|
# It is available only since PD 10.
|
19
21
|
if env[:machine].provider.pd_version_satisfies?('>= 10')
|
@@ -22,18 +24,27 @@ module VagrantPlugins
|
|
22
24
|
env[:machine].provider.driver.disable_password_restrictions(acts)
|
23
25
|
end
|
24
26
|
|
27
|
+
if env[:machine].provider_config.regen_src_uuid \
|
28
|
+
&& env[:machine].provider.pd_version_satisfies?('>= 10.1.2')
|
29
|
+
options[:regenerate_src_uuid] = true
|
30
|
+
end
|
31
|
+
|
25
32
|
# Linked clones are supported only for PD 11 and higher
|
26
33
|
if env[:machine].provider_config.linked_clone \
|
27
34
|
&& env[:machine].provider.pd_version_satisfies?('>= 11')
|
28
35
|
# Linked clone creation should not be concurrent [GH-206]
|
36
|
+
options[:snapshot_id] = env[:clone_snapshot_id]
|
37
|
+
options[:linked] = true
|
29
38
|
@@lock.synchronize do
|
30
39
|
lock_key = Digest::MD5.hexdigest("#{env[:clone_id]}-linked-clone")
|
31
40
|
env[:machine].env.lock(lock_key, retry: true) do
|
32
|
-
|
41
|
+
env[:ui].info I18n.t('vagrant_parallels.actions.vm.clone.linked')
|
42
|
+
clone(env, options)
|
33
43
|
end
|
34
44
|
end
|
35
45
|
else
|
36
|
-
|
46
|
+
env[:ui].info I18n.t('vagrant_parallels.actions.vm.clone.full')
|
47
|
+
clone(env, options)
|
37
48
|
end
|
38
49
|
|
39
50
|
# If we got interrupted, then the import could have been
|
@@ -44,7 +55,7 @@ module VagrantPlugins
|
|
44
55
|
raise Errors::VMCloneFailure if !env[:machine].id
|
45
56
|
|
46
57
|
if env[:machine].provider_config.regen_src_uuid \
|
47
|
-
&& env[:machine].provider.pd_version_satisfies?('<
|
58
|
+
&& env[:machine].provider.pd_version_satisfies?('< 10.1.2')
|
48
59
|
@logger.info('Regenerate SourceVmUuid by editing config.pvs file')
|
49
60
|
env[:machine].provider.driver.regenerate_src_uuid
|
50
61
|
end
|
@@ -88,27 +99,9 @@ module VagrantPlugins
|
|
88
99
|
|
89
100
|
protected
|
90
101
|
|
91
|
-
def
|
92
|
-
env[:ui].info I18n.t('vagrant_parallels.actions.vm.clone.full')
|
93
|
-
env[:machine].id = env[:machine].provider.driver.clone_vm(
|
94
|
-
env[:clone_id]) do |progress|
|
95
|
-
env[:ui].clear_line
|
96
|
-
env[:ui].report_progress(progress, 100, false)
|
97
|
-
end
|
98
|
-
|
99
|
-
# Clear the line one last time since the progress meter doesn't disappear
|
100
|
-
# immediately.
|
101
|
-
env[:ui].clear_line
|
102
|
-
end
|
103
|
-
|
104
|
-
def clone_linked(env)
|
105
|
-
opts = {
|
106
|
-
snapshot_id: env[:clone_snapshot_id],
|
107
|
-
linked: true
|
108
|
-
}
|
109
|
-
env[:ui].info I18n.t('vagrant_parallels.actions.vm.clone.linked')
|
102
|
+
def clone(env, options)
|
110
103
|
env[:machine].id = env[:machine].provider.driver.clone_vm(
|
111
|
-
env[:clone_id],
|
104
|
+
env[:clone_id], options) do |progress|
|
112
105
|
env[:ui].clear_line
|
113
106
|
env[:ui].report_progress(progress, 100, false)
|
114
107
|
end
|
@@ -67,6 +67,9 @@ module VagrantPlugins
|
|
67
67
|
args << '--linked' if options[:linked]
|
68
68
|
args.concat(['--id', options[:snapshot_id]]) if options[:snapshot_id]
|
69
69
|
|
70
|
+
# Regenerate SourceVmUuid of the cloned VM
|
71
|
+
args << '--regenerate-src-uuid' if options[:regenerate_src_uuid]
|
72
|
+
|
70
73
|
execute_prlctl(*args) do |_, data|
|
71
74
|
lines = data.split('\r')
|
72
75
|
# The progress of the clone will be in the last line. Do a greedy
|
@@ -526,25 +529,7 @@ module VagrantPlugins
|
|
526
529
|
# @param [String] pvm_file Path to the machine image (*.pvm)
|
527
530
|
# @param [Array<String>] opts List of options for "prlctl register"
|
528
531
|
def register(pvm_file, opts=[])
|
529
|
-
|
530
|
-
|
531
|
-
3.times do
|
532
|
-
result = raw(*args)
|
533
|
-
# Exit if everything is OK
|
534
|
-
return if result.exit_code == 0
|
535
|
-
|
536
|
-
# It may occur in the race condition with other Vagrant processes.
|
537
|
-
# It is OK, just exit.
|
538
|
-
return if result.stderr.include?('is already registered.')
|
539
|
-
|
540
|
-
# Sleep a bit though to give Parallels Desktop time to fix itself
|
541
|
-
sleep 2
|
542
|
-
end
|
543
|
-
|
544
|
-
# If we reach this point, it means that we consistently got the
|
545
|
-
# failure, do a standard execute now. This will raise an
|
546
|
-
# exception if it fails again.
|
547
|
-
execute(*args)
|
532
|
+
execute_prlctl('register', pvm_file, *opts)
|
548
533
|
end
|
549
534
|
|
550
535
|
# Switches the VM state to the specified snapshot
|
@@ -619,25 +604,7 @@ module VagrantPlugins
|
|
619
604
|
# Virtual machine will be removed from the VM list, but its image will
|
620
605
|
# not be deleted from the disk. So, it can be registered again.
|
621
606
|
def unregister(uuid)
|
622
|
-
|
623
|
-
3.times do
|
624
|
-
result = raw(*args)
|
625
|
-
# Exit if everything is OK
|
626
|
-
return if result.exit_code == 0
|
627
|
-
|
628
|
-
# It may occur in the race condition with other Vagrant processes.
|
629
|
-
# Both are OK, just exit.
|
630
|
-
return if result.stderr.include?('is not registered')
|
631
|
-
return if result.stderr.include?('is being cloned')
|
632
|
-
|
633
|
-
# Sleep a bit though to give Parallels Desktop time to fix itself
|
634
|
-
sleep 2
|
635
|
-
end
|
636
|
-
|
637
|
-
# If we reach this point, it means that we consistently got the
|
638
|
-
# failure, do a standard execute now. This will raise an
|
639
|
-
# exception if it fails again.
|
640
|
-
execute(*args)
|
607
|
+
execute_prlctl('unregister', uuid)
|
641
608
|
end
|
642
609
|
|
643
610
|
# Unshare folders.
|
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.6.
|
4
|
+
version: 1.6.1
|
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:
|
12
|
+
date: 2016-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|