vagrant-parallels 1.5.0 → 1.5.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
  SHA1:
3
- metadata.gz: c554494202e2c1a84d300f15a096202837c82dca
4
- data.tar.gz: 02f21dfce1b2911c09d16a775cd55fb4e71cd420
3
+ metadata.gz: f733216d1fb00b3fb1b57306e793948845e77c85
4
+ data.tar.gz: 00a71db6979da474580c398aa1ca4c07c18175c5
5
5
  SHA512:
6
- metadata.gz: d46a3ea4ffc68f3cc93dbcdf80b2c5d61c11ae3db067c851b4fdfd3828b85b1ed4902388d3b52bb270ac7d2837a448ff7da609fa443f5e081efffa4aeb8db1e6
7
- data.tar.gz: 7f137247396772bc9c5f42fa6bf412adf420ac041b126103f9f935abed99cbd914850e8c6e50289685656285fdcdcd589d18ef68438c35fd2c1a6726cedd0204
6
+ metadata.gz: 7ee1b240e58e12d5f289ce83a6c0e5f3b008281e204450d7bda03078dcbca59a2e76b5de0632daab49cd03e4e2b911ccccb59413251173e3522656f9b19b9637
7
+ data.tar.gz: 01f7add1fbe46e5e3732fd3e15a2574ce762712c10bd3d1f6f989ccc12de1f2becea53a93089af3126e0443accc997e9b56f45bc19f440730d3fac738bac945e
@@ -454,8 +454,8 @@ module VagrantPlugins
454
454
  # @return [<String => String>]
455
455
  def read_vms
456
456
  args = %w(list --all --no-header --json -o name,uuid)
457
- vms_arr = json([]) { execute_prlctl(*args) }
458
- templates_arr = json([]) { execute_prlctl(*args, '--template') }
457
+ vms_arr = json { execute_prlctl(*args) }
458
+ templates_arr = json { execute_prlctl(*args, '--template') }
459
459
 
460
460
  vms = vms_arr | templates_arr
461
461
  Hash[vms.map { |i| [i.fetch('name'), i.fetch('uuid')] }]
@@ -466,8 +466,8 @@ module VagrantPlugins
466
466
  # @return [Array <String => String>]
467
467
  def read_vms_info
468
468
  args = %w(list --all --info --no-header --json)
469
- vms_arr = json([]) { execute_prlctl(*args) }
470
- templates_arr = json([]) { execute_prlctl(*args, '--template') }
469
+ vms_arr = json { execute_prlctl(*args) }
470
+ templates_arr = json { execute_prlctl(*args, '--template') }
471
471
 
472
472
  vms_arr | templates_arr
473
473
  end
@@ -670,14 +670,26 @@ module VagrantPlugins
670
670
  end
671
671
 
672
672
  # Parses given block (JSON string) to object
673
- def json(default=nil)
673
+ def json
674
674
  data = yield
675
+ raise_error = false
676
+
675
677
  begin
676
678
  JSON.parse(data)
677
- rescue JSON::ParserError
678
- # Try to cleanup the data and parse it again [GH-204]
679
+ rescue JSON::JSONError
680
+ # We retried already, raise the issue and be done
681
+ if raise_error
682
+ raise VagrantPlugins::Parallels::Errors::JSONParseError, data: data
683
+ end
684
+
685
+ # Remove garbage before/after json string[GH-204]
679
686
  data = data[/(\{.*\}|\[.*\])/m]
680
- JSON.parse(data) rescue default
687
+
688
+ # Remove all control characters unsupported by JSON [GH-219]
689
+ data.tr!("\u0000-\u001f", '')
690
+
691
+ raise_error = true
692
+ retry
681
693
  end
682
694
  end
683
695
 
@@ -117,7 +117,7 @@ module VagrantPlugins
117
117
  #
118
118
  # @return [String]
119
119
  def read_edition
120
- lic_info = json({}) do
120
+ lic_info = json do
121
121
  execute(@prlsrvctl_path, 'info', '--license', '--json')
122
122
  end
123
123
  lic_info['edition']
@@ -11,6 +11,10 @@ module VagrantPlugins
11
11
  error_key(:dhcp_leases_file_not_accessible)
12
12
  end
13
13
 
14
+ class JSONParseError < VagrantParallelsError
15
+ error_key(:json_parse_error)
16
+ end
17
+
14
18
  class LinuxMountFailed < VagrantParallelsError
15
19
  error_key(:linux_mount_failed)
16
20
  end
@@ -105,7 +105,7 @@ module VagrantPlugins
105
105
  end
106
106
 
107
107
  def os_friendly_id(id)
108
- id.gsub(/[\/]/,'_').sub(/^_/, '')
108
+ id.gsub(/[\/:]/,'_').sub(/^_/, '')
109
109
  end
110
110
  end
111
111
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = '1.5.0'
3
+ VERSION = '1.5.1'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -20,6 +20,12 @@ en:
20
20
 
21
21
  Stderr: %{stderr}
22
22
 
23
+ json_parse_error: |-
24
+ Failed to parse the JSON string! Please report this as a bug of Parallels
25
+ provider: https://github.com/Parallels/vagrant-parallels/issues
26
+ JSON string is shown below:
27
+
28
+ %{data}
23
29
  linux_mount_failed: |-
24
30
  Failed to mount folders in Linux guest. This is usually because
25
31
  the "prl_fs" file system is not available. Please verify that
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.5.0
4
+ version: 1.5.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: 2015-09-29 00:00:00.000000000 Z
12
+ date: 2015-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler