vagrant-parallels 2.4.0 → 2.4.1

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
  SHA256:
3
- metadata.gz: 340fd7bc7a4c4903ee2f67a21435abbd27d0fd3ae531e6e2f45b78d6d40749c6
4
- data.tar.gz: ec86770f0a873be4d766e53df5a2ebbae3982924be8ee7974107cdd763a7da55
3
+ metadata.gz: 5316a81fe9c64de94bb88a2db7b9efcc015325d4b95bd4ec6302f7441334e0c3
4
+ data.tar.gz: d493a896f4b9776f2755038d333046c6fa920f7e1fdd45de96dee0ae4cf33ef4
5
5
  SHA512:
6
- metadata.gz: fa1430cfa50873ac14648f6d1c8269812850be959ada747366a669ca7003fbde48460b4e145ef4d193cbfe6ef47cff52bf0db20ea05b2a4fc768e914f9e1cbdc
7
- data.tar.gz: '07178f61772a66d419117fa8bbabf953aa4d82b76e47952bba691d6b9ef38ceea92561314df94b3f13dd9712a701a2feb5480b80604785e048650be75ae212b9'
6
+ metadata.gz: 874be6069e0cf9ec4ee115d75b7979bd68a1c007d04f0552dae2a808d7025c8659926a906ce37814ee19c7c2e04ef7b753d2c5b1d2121f8670092a40b77b5248
7
+ data.tar.gz: 53435b75213e446b68d679f2600d47e70cc4d5fec8141d9be6e9eba270030cfa9f3d48cf398d5ce07311503de8a053802fb1629408bd49e5f49d25cbf40d0562
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 2.4.0 (May 22, 2023)
2
+ IMPROVEMENTS:
3
+ - use clonefile copy for macvm boxes
4
+ [[GH-459](https://github.com/Parallels/vagrant-parallels/pull/459)]
5
+
6
+ BUG FIXES:
7
+ - Bump activesupport from 6.1.7.3 to 6.1.7.5
8
+ [[GH-457](https://github.com/Parallels/vagrant-parallels/pull/457)]
9
+ - Don't try to call methdods on Nil
10
+ [[GH-456](https://github.com/Parallels/vagrant-parallels/pull/456)]
11
+ - Add a doc note for releasing a new provider version
12
+ [[GH-452](https://github.com/Parallels/vagrant-parallels/pull/452)]
13
+ - website: Remove unused images
14
+ [[GH-450](https://github.com/Parallels/vagrant-parallels/pull/450)]
15
+ - adding macos
16
+ [[GH-447](https://github.com/Parallels/vagrant-parallels/pull/447)]
17
+
1
18
  ## 2.4.0 (May 22, 2023)
2
19
  IMPROVEMENTS:
3
20
  - Implement shared folder support for `.macvm` VMs
@@ -78,7 +78,26 @@ module VagrantPlugins
78
78
  # @return [String] UUID of the new VM.
79
79
  def clone_vm(src_name, options = {})
80
80
  dst_name = "vagrant_temp_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
81
+ src_vm = json { execute_prlctl('list', '--json', '-i', src_name) }.first
81
82
 
83
+ if options[:linked] || !Util::Common.is_apfs?(src_vm.fetch('Home'))
84
+ # If linked clone is an option, or path to src is not on APFS, then do the normal clone.
85
+ prlctl_clone_vm(src_name, dst_name, options)
86
+ else
87
+ # We can use clonefile on APFS to do a fast CoW clone of the VM source and then register
88
+ copy_clone_vm(src_name, dst_name, options)
89
+ end
90
+ read_vms[dst_name]
91
+ end
92
+
93
+ # Uses prlctl to clone an existing registered VM
94
+ #
95
+ # @param [String] src_name Name or UUID of the source VM or template.
96
+ # @param [String] dst_name Name of the destination VM.
97
+ # @param [<String => String>] options Options to clone virtual machine.
98
+ def prlctl_clone_vm(src_name, dst_name, options = {})
99
+ list_args = ['list', '--json', '-i', src_name]
100
+ src_vm = json { execute_prlctl(*list_args) }.first
82
101
  args = ['clone', src_name, '--name', dst_name]
83
102
  args.concat(['--dst', options[:dst]]) if options[:dst]
84
103
 
@@ -97,7 +116,41 @@ module VagrantPlugins
97
116
  yield $1.to_i if block_given?
98
117
  end
99
118
  end
100
- read_vms[dst_name]
119
+ end
120
+
121
+ # Uses cp with clonefile flag to clone an existing registered VM
122
+ #
123
+ # @param [String] src_name Name or UUID of the source VM or template.
124
+ # @param [String] dst_name Name of the destination VM.
125
+ # @param [<String => String>] options Options to clone virtual machine.
126
+ def copy_clone_vm(src_name, dst_name, options = {})
127
+ list_args = ['list', '--json', '-i', src_name]
128
+ src_vm = json { execute_prlctl(*list_args) }.first
129
+ basepath = File.dirname(src_vm.fetch('Home')).delete_suffix('/')
130
+ extension = File.basename(src_vm.fetch('Home')).delete_suffix('/').split('.').last
131
+ clonepath = File.join(ENV['HOME'], "Parallels", "#{dst_name}.#{extension}")
132
+ execute('cp', '-c', '-R', '-p', src_vm.fetch('Home'), clonepath)
133
+
134
+ # Update config.pvs with dst_name as this is what Parallels uses when registering
135
+ update_vm_name(File.join(clonepath, 'config.pvs'), dst_name)
136
+
137
+ # Register the cloned path as a new VM
138
+ args = ['register', clonepath]
139
+ # Regenerate SourceVmUuid of the cloned VM
140
+ args << '--regenerate-src-uuid' if options[:regenerate_src_uuid]
141
+
142
+ # Regenerate SourceVmUuid of the cloned VM
143
+ execute_prlctl(*args)
144
+
145
+ # Don't need the box hanging around in Parallels
146
+ execute_prlctl('unregister', src_name)
147
+ end
148
+
149
+ def update_vm_name(config_pvs_path, name)
150
+ xml = Nokogiri::XML(File.read(config_pvs_path))
151
+ elem = xml.at_xpath('//ParallelsVirtualMachine/Identification/VmName')
152
+ elem.content = name
153
+ File.write(config_pvs_path, xml.to_xml)
101
154
  end
102
155
 
103
156
  # Compacts the specified virtual disk image
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  module VagrantPlugins
2
4
  module Parallels
3
5
  module Util
@@ -6,9 +8,26 @@ module VagrantPlugins
6
8
  # Determines whether the VM's box contains a macOS guest for an Apple Silicon host.
7
9
  # In this case the image file ends with '.macvm' instead of '.pvm'
8
10
  def self.is_macvm(machine)
9
- return !!Dir.glob(machine.box.directory.join('*.macvm')).first
11
+ return !machine.box.nil? && !!Dir.glob(machine.box.directory.join('*.macvm')).first
12
+ end
13
+
14
+ # Determines if the box directory is on an APFS filesystem
15
+ def self.is_apfs?(path, &block)
16
+ output = {stdout: '', stderr: ''}
17
+ df_command = %w[df -T apfs]
18
+ df_command << Shellwords.escape(path)
19
+ execute(*df_command, &block).exit_code == 0
10
20
  end
11
21
 
22
+ private
23
+
24
+ def self.execute(*command, &block)
25
+ command << { notify: [:stdout, :stderr] }
26
+
27
+ Vagrant::Util::Busy.busy(lambda {}) do
28
+ Vagrant::Util::Subprocess.execute(*command, &block)
29
+ end
30
+ end
12
31
  end
13
32
  end
14
33
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = '2.4.0'
3
+ VERSION = '2.4.1'
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: 2.4.0
4
+ version: 2.4.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: 2023-05-22 00:00:00.000000000 Z
12
+ date: 2023-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: 1.3.6
169
169
  requirements: []
170
- rubygems_version: 3.2.33
170
+ rubygems_version: 3.4.10
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Parallels provider for Vagrant.