vagrant-parallels 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vagrant-parallels/action/prepare_nfs_settings.rb +8 -3
- data/lib/vagrant-parallels/action.rb +2 -2
- data/lib/vagrant-parallels/driver/prl_ctl.rb +145 -116
- data/lib/vagrant-parallels/version.rb +1 -1
- metadata +5 -11
- data/sandi_meter/assets/chart.js +0 -12
- data/sandi_meter/assets/forkme.png +0 -0
- data/sandi_meter/assets/jquery.js +0 -6
- data/sandi_meter/assets/morris.css +0 -2
- data/sandi_meter/assets/normalize.css +0 -406
- data/sandi_meter/assets/script.js +0 -83
- data/sandi_meter/assets/style.css +0 -128
- data/sandi_meter/index.html +0 -392
- data/sandi_meter/sandi_meter.log +0 -1
@@ -35,7 +35,7 @@ module VagrantPlugins
|
|
35
35
|
machine.provider.driver.read_network_interfaces.each do |adapter, opts|
|
36
36
|
if opts[:type] == :hostonly
|
37
37
|
machine.provider.driver.read_host_only_interfaces.each do |interface|
|
38
|
-
if interface[:
|
38
|
+
if interface[:bound_to] == opts[:hostonly]
|
39
39
|
return interface[:ip]
|
40
40
|
end
|
41
41
|
end
|
@@ -50,13 +50,18 @@ module VagrantPlugins
|
|
50
50
|
#
|
51
51
|
# @return [String]
|
52
52
|
def read_machine_ip(machine)
|
53
|
+
ips = []
|
53
54
|
machine.config.vm.networks.each do |type, options|
|
54
55
|
if type == :private_network && options[:ip].is_a?(String)
|
55
|
-
|
56
|
+
ips << options[:ip]
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
|
60
|
+
if ips.empty?
|
61
|
+
return nil
|
62
|
+
end
|
63
|
+
|
64
|
+
ips
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
@@ -20,7 +20,7 @@ module VagrantPlugins
|
|
20
20
|
# b.use HandleForwardedPortCollisions
|
21
21
|
b.use PruneNFSExports
|
22
22
|
b.use NFS
|
23
|
-
|
23
|
+
b.use PrepareNFSSettings
|
24
24
|
b.use ClearSharedFolders
|
25
25
|
b.use ShareFolders
|
26
26
|
b.use Network
|
@@ -268,7 +268,6 @@ module VagrantPlugins
|
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
271
|
-
#autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
|
272
271
|
autoload :Boot, File.expand_path("../action/boot", __FILE__)
|
273
272
|
autoload :CheckAccessible, File.expand_path("../action/check_accessible", __FILE__)
|
274
273
|
autoload :CheckCreated, File.expand_path("../action/check_created", __FILE__)
|
@@ -295,6 +294,7 @@ module VagrantPlugins
|
|
295
294
|
autoload :Network, File.expand_path("../action/network", __FILE__)
|
296
295
|
autoload :Package, File.expand_path("../action/package", __FILE__)
|
297
296
|
autoload :PackageConfigFiles, File.expand_path("../action/package_config_files", __FILE__)
|
297
|
+
autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
|
298
298
|
autoload :PruneNFSExports, File.expand_path("../action/prune_nfs_exports", __FILE__)
|
299
299
|
autoload :RegisterTemplate, File.expand_path("../action/register_template", __FILE__)
|
300
300
|
autoload :Resume, File.expand_path("../action/resume", __FILE__)
|
@@ -38,6 +38,19 @@ module VagrantPlugins
|
|
38
38
|
@logger.info("CLI prlsrvctl path: #{@prlsrvctl_path}")
|
39
39
|
end
|
40
40
|
|
41
|
+
def compact(uuid=nil)
|
42
|
+
uuid ||= @uuid
|
43
|
+
path_to_hdd = read_settings(uuid).fetch("Hardware", {}).fetch("hdd0", {}).fetch("image", nil)
|
44
|
+
raw('prl_disk_tool', 'compact', '--hdd', path_to_hdd) do |type, data|
|
45
|
+
lines = data.split("\r")
|
46
|
+
# The progress of the import will be in the last line. Do a greedy
|
47
|
+
# regular expression to find what we're looking for.
|
48
|
+
if lines.last =~ /.+?(\d{,3}) ?%/
|
49
|
+
yield $1.to_i if block_given?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
def create_host_only_network(options)
|
42
55
|
# Create the interface
|
43
56
|
execute(:prlsrvctl, "net", "add", options[:name], "--type", "host-only")
|
@@ -66,6 +79,24 @@ module VagrantPlugins
|
|
66
79
|
}
|
67
80
|
end
|
68
81
|
|
82
|
+
def clear_shared_folders
|
83
|
+
read_settings.fetch("Host Shared Folders", {}).keys.drop(1).each do |folder|
|
84
|
+
execute("set", @uuid, "--shf-host-del", folder)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def delete
|
89
|
+
execute('delete', @uuid)
|
90
|
+
end
|
91
|
+
|
92
|
+
def delete_adapters
|
93
|
+
read_settings.fetch('Hardware', {}).each do |adapter, params|
|
94
|
+
if adapter.start_with?('net') and !params.fetch("enabled", true)
|
95
|
+
execute('set', @uuid, '--device-del', adapter)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
69
100
|
def delete_unused_host_only_networks
|
70
101
|
networks = read_virtual_networks()
|
71
102
|
|
@@ -141,11 +172,45 @@ module VagrantPlugins
|
|
141
172
|
end
|
142
173
|
end
|
143
174
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
175
|
+
def export(path, vm_name)
|
176
|
+
execute("clone", @uuid, "--name", vm_name, "--template", "--dst", path.to_s) do |type, data|
|
177
|
+
lines = data.split("\r")
|
178
|
+
# The progress of the import will be in the last line. Do a greedy
|
179
|
+
# regular expression to find what we're looking for.
|
180
|
+
if lines.last =~ /.+?(\d{,3}) ?%/
|
181
|
+
yield $1.to_i if block_given?
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
read_settings(vm_name).fetch('ID', vm_name)
|
186
|
+
end
|
187
|
+
|
188
|
+
def halt(force=false)
|
189
|
+
args = ['stop', @uuid]
|
190
|
+
args << '--kill' if force
|
191
|
+
execute(*args)
|
192
|
+
end
|
193
|
+
|
194
|
+
def import(template_uuid, vm_name)
|
195
|
+
execute("clone", template_uuid, '--name', vm_name) do |type, data|
|
196
|
+
lines = data.split("\r")
|
197
|
+
# The progress of the import will be in the last line. Do a greedy
|
198
|
+
# regular expression to find what we're looking for.
|
199
|
+
if lines.last =~ /.+?(\d{,3}) ?%/
|
200
|
+
yield $1.to_i if block_given?
|
201
|
+
end
|
202
|
+
end
|
203
|
+
@uuid = read_settings(vm_name).fetch('ID', vm_name)
|
204
|
+
end
|
205
|
+
|
206
|
+
def ip
|
207
|
+
mac_addr = read_mac_address.downcase
|
208
|
+
File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
|
209
|
+
if line.include? mac_addr
|
210
|
+
ip = line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
|
211
|
+
return ip
|
212
|
+
end
|
213
|
+
end
|
149
214
|
end
|
150
215
|
|
151
216
|
# Returns a hash of all UUIDs assigned to VMs and templates currently
|
@@ -212,6 +277,10 @@ module VagrantPlugins
|
|
212
277
|
bridged_ifaces
|
213
278
|
end
|
214
279
|
|
280
|
+
def read_guest_tools_version
|
281
|
+
read_settings.fetch('GuestTools', {}).fetch('version', nil)
|
282
|
+
end
|
283
|
+
|
215
284
|
def read_host_only_interfaces
|
216
285
|
net_list = read_virtual_networks()
|
217
286
|
net_list.keep_if { |net| net['Type'] == "host-only" }
|
@@ -247,121 +316,71 @@ module VagrantPlugins
|
|
247
316
|
read_settings.fetch('Hardware', {}).fetch('net0', {}).fetch('mac', nil)
|
248
317
|
end
|
249
318
|
|
250
|
-
def
|
251
|
-
|
252
|
-
end
|
253
|
-
|
254
|
-
# Verifies that the driver is ready to accept work.
|
255
|
-
#
|
256
|
-
# This should raise a VagrantError if things are not ready.
|
257
|
-
def verify!
|
258
|
-
# TODO: Use version method?
|
259
|
-
execute('--version')
|
260
|
-
end
|
319
|
+
def read_network_interfaces
|
320
|
+
nics = {}
|
261
321
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
|
-
def clear_shared_folders
|
268
|
-
read_settings.fetch("Host Shared Folders", {}).keys.drop(1).each do |folder|
|
269
|
-
execute("set", @uuid, "--shf-host-del", folder)
|
322
|
+
# Get enabled VM's network interfaces
|
323
|
+
ifaces = read_settings.fetch('Hardware', {}).keep_if do |dev, params|
|
324
|
+
dev.start_with?('net') and params.fetch("enabled", true)
|
270
325
|
end
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
execute('set', @uuid, '--device-del', adapter)
|
326
|
+
ifaces.each do |name, params|
|
327
|
+
adapter = name.match(/^net(\d+)$/)[1].to_i
|
328
|
+
nics[adapter] ||= {}
|
329
|
+
|
330
|
+
if params['type'] == "shared"
|
331
|
+
nics[adapter][:type] = :shared
|
332
|
+
elsif params['type'] == "host"
|
333
|
+
# It is PD internal host-only network and it is bounded to 'vnic1'
|
334
|
+
nics[adapter][:type] = :hostonly
|
335
|
+
nics[adapter][:hostonly] = "vnic1"
|
336
|
+
elsif params['type'] == "bridged" and params.fetch('iface','').start_with?('vnic')
|
337
|
+
# Bridged to the 'vnicXX'? Then it is a host-only, actually.
|
338
|
+
nics[adapter][:type] = :hostonly
|
339
|
+
nics[adapter][:hostonly] = params.fetch('iface','')
|
340
|
+
elsif params['type'] == "bridged"
|
341
|
+
nics[adapter][:type] = :bridged
|
342
|
+
nics[adapter][:bridge] = params.fetch('iface','')
|
289
343
|
end
|
290
344
|
end
|
345
|
+
nics
|
291
346
|
end
|
292
347
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
execute('suspend', @uuid)
|
299
|
-
end
|
300
|
-
|
301
|
-
def start
|
302
|
-
execute('start', @uuid)
|
303
|
-
end
|
304
|
-
|
305
|
-
def halt(force=false)
|
306
|
-
args = ['stop', @uuid]
|
307
|
-
args << '--kill' if force
|
308
|
-
execute(*args)
|
309
|
-
end
|
310
|
-
|
311
|
-
def delete
|
312
|
-
execute('delete', @uuid)
|
348
|
+
# Returns the current state of this VM.
|
349
|
+
#
|
350
|
+
# @return [Symbol]
|
351
|
+
def read_state
|
352
|
+
read_settings(@uuid).fetch('State', 'inaccessible').to_sym
|
313
353
|
end
|
314
354
|
|
315
|
-
def
|
316
|
-
execute(
|
317
|
-
lines = data.split("\r")
|
318
|
-
# The progress of the import will be in the last line. Do a greedy
|
319
|
-
# regular expression to find what we're looking for.
|
320
|
-
if lines.last =~ /.+?(\d{,3}) ?%/
|
321
|
-
yield $1.to_i if block_given?
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
read_settings(vm_name).fetch('ID', vm_name)
|
355
|
+
def read_virtual_networks
|
356
|
+
json { execute(:prlsrvctl, 'net', 'list', '--json', retryable: true) }
|
326
357
|
end
|
327
358
|
|
328
|
-
def
|
329
|
-
|
330
|
-
path_to_hdd = read_settings(uuid).fetch("Hardware", {}).fetch("hdd0", {}).fetch("image", nil)
|
331
|
-
raw('prl_disk_tool', 'compact', '--hdd', path_to_hdd) do |type, data|
|
332
|
-
lines = data.split("\r")
|
333
|
-
# The progress of the import will be in the last line. Do a greedy
|
334
|
-
# regular expression to find what we're looking for.
|
335
|
-
if lines.last =~ /.+?(\d{,3}) ?%/
|
336
|
-
yield $1.to_i if block_given?
|
337
|
-
end
|
338
|
-
end
|
359
|
+
def ready?
|
360
|
+
!!guest_execute('uname') rescue false
|
339
361
|
end
|
340
362
|
|
341
363
|
def register(pvm_file)
|
342
364
|
execute("register", pvm_file)
|
343
365
|
end
|
344
366
|
|
345
|
-
def unregister(uuid)
|
346
|
-
execute("unregister", uuid)
|
347
|
-
end
|
348
|
-
|
349
367
|
def registered?(path)
|
350
368
|
# TODO: Make this take UUID and have callers pass that instead
|
351
369
|
# Need a way to get the UUID from unregistered templates though (config.pvs XML parsing/regex?)
|
352
370
|
read_all_paths.has_key?(path)
|
353
371
|
end
|
354
372
|
|
355
|
-
def
|
356
|
-
execute('
|
373
|
+
def resume
|
374
|
+
execute('resume', @uuid)
|
357
375
|
end
|
358
376
|
|
359
|
-
def
|
360
|
-
|
377
|
+
def set_mac_address(mac)
|
378
|
+
execute('set', @uuid, '--device-set', 'net0', '--type', 'shared', '--mac', mac)
|
361
379
|
end
|
362
380
|
|
363
|
-
|
364
|
-
|
381
|
+
# apply custom vm setting via set parameter
|
382
|
+
def set_vm_settings(command)
|
383
|
+
raw(@manager_path, *command)
|
365
384
|
end
|
366
385
|
|
367
386
|
def share_folders(folders)
|
@@ -371,27 +390,46 @@ module VagrantPlugins
|
|
371
390
|
end
|
372
391
|
end
|
373
392
|
|
374
|
-
def
|
375
|
-
|
393
|
+
def ssh_port(expected_port)
|
394
|
+
22
|
376
395
|
end
|
377
396
|
|
378
|
-
def
|
379
|
-
|
380
|
-
File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
|
381
|
-
if line.include? mac_addr
|
382
|
-
ip = line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
|
383
|
-
return ip
|
384
|
-
end
|
385
|
-
end
|
397
|
+
def start
|
398
|
+
execute('start', @uuid)
|
386
399
|
end
|
387
400
|
|
388
|
-
|
389
|
-
|
390
|
-
|
401
|
+
def suspend
|
402
|
+
execute('suspend', @uuid)
|
403
|
+
end
|
404
|
+
|
405
|
+
def unregister(uuid)
|
406
|
+
execute("unregister", uuid)
|
407
|
+
end
|
408
|
+
|
409
|
+
# Verifies that the driver is ready to accept work.
|
410
|
+
#
|
411
|
+
# This should raise a VagrantError if things are not ready.
|
412
|
+
def verify!
|
413
|
+
# TODO: Use version method?
|
414
|
+
execute('--version')
|
415
|
+
end
|
416
|
+
|
417
|
+
def version
|
418
|
+
raw_version = execute('--version', retryable: true)
|
419
|
+
raw_version.gsub('/prlctl version /', '')
|
391
420
|
end
|
392
421
|
|
393
422
|
private
|
394
423
|
|
424
|
+
def guest_execute(*command)
|
425
|
+
execute('exec', @uuid, *command)
|
426
|
+
end
|
427
|
+
|
428
|
+
def json(default=nil)
|
429
|
+
data = yield
|
430
|
+
JSON.parse(data) rescue default
|
431
|
+
end
|
432
|
+
|
395
433
|
# Parse the JSON from *all* VMs and templates. Then return an array of objects (without duplicates)
|
396
434
|
def read_all_info
|
397
435
|
vms_arr = json({}) do
|
@@ -408,15 +446,6 @@ module VagrantPlugins
|
|
408
446
|
json({}) { execute('list', uuid, '--info', '--json', retryable: true).gsub(/^(INFO)?\[/, '').gsub(/\]$/, '') }
|
409
447
|
end
|
410
448
|
|
411
|
-
def json(default=nil)
|
412
|
-
data = yield
|
413
|
-
JSON.parse(data) rescue default
|
414
|
-
end
|
415
|
-
|
416
|
-
def guest_execute(*command)
|
417
|
-
execute('exec', @uuid, *command)
|
418
|
-
end
|
419
|
-
|
420
449
|
def error_detection(command_response)
|
421
450
|
errored = false
|
422
451
|
# If the command was a failure, then raise an exception that is
|
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: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -147,15 +147,6 @@ files:
|
|
147
147
|
- locales/en.yml
|
148
148
|
- Rakefile
|
149
149
|
- README.md
|
150
|
-
- sandi_meter/assets/chart.js
|
151
|
-
- sandi_meter/assets/forkme.png
|
152
|
-
- sandi_meter/assets/jquery.js
|
153
|
-
- sandi_meter/assets/morris.css
|
154
|
-
- sandi_meter/assets/normalize.css
|
155
|
-
- sandi_meter/assets/script.js
|
156
|
-
- sandi_meter/assets/style.css
|
157
|
-
- sandi_meter/index.html
|
158
|
-
- sandi_meter/sandi_meter.log
|
159
150
|
- spec/vagrant-parallels/setup_spec.rb
|
160
151
|
- vagrant-parallels.gemspec
|
161
152
|
- .gitignore
|
@@ -173,6 +164,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
164
|
- - ! '>='
|
174
165
|
- !ruby/object:Gem::Version
|
175
166
|
version: '0'
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
hash: 3847391390300994580
|
176
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
171
|
none: false
|
178
172
|
requirements:
|