vagrant-parallels 1.0.9.rc1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vagrant-parallels/action.rb +121 -122
  3. data/lib/vagrant-parallels/action/customize.rb +2 -3
  4. data/lib/vagrant-parallels/action/handle_guest_tools.rb +51 -0
  5. data/lib/vagrant-parallels/action/import.rb +1 -1
  6. data/lib/vagrant-parallels/action/is_driver_version.rb +28 -0
  7. data/lib/vagrant-parallels/action/set_power_consumption.rb +2 -6
  8. data/lib/vagrant-parallels/config.rb +6 -0
  9. data/lib/vagrant-parallels/driver/base.rb +42 -57
  10. data/lib/vagrant-parallels/driver/meta.rb +4 -5
  11. data/lib/vagrant-parallels/driver/pd_8.rb +80 -50
  12. data/lib/vagrant-parallels/driver/pd_9.rb +7 -7
  13. data/lib/vagrant-parallels/errors.rb +8 -4
  14. data/lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb +53 -0
  15. data/lib/vagrant-parallels/plugin.rb +7 -2
  16. data/lib/vagrant-parallels/version.rb +1 -1
  17. data/locales/en.yml +34 -29
  18. data/test/unit/driver/pd_8_test.rb +3 -0
  19. data/test/unit/driver/pd_9_test.rb +3 -0
  20. data/test/unit/support/shared/pd_driver_examples.rb +33 -9
  21. metadata +5 -14
  22. data/lib/vagrant-parallels/action/check_accessible.rb +0 -23
  23. data/lib/vagrant-parallels/action/check_created.rb +0 -21
  24. data/lib/vagrant-parallels/action/check_guest_tools.rb +0 -37
  25. data/lib/vagrant-parallels/action/check_parallels.rb +0 -22
  26. data/lib/vagrant-parallels/action/check_running.rb +0 -21
  27. data/lib/vagrant-parallels/action/created.rb +0 -20
  28. data/lib/vagrant-parallels/action/is_running.rb +0 -20
  29. data/lib/vagrant-parallels/action/is_suspended.rb +0 -21
  30. data/lib/vagrant-parallels/action/message_already_running.rb +0 -16
  31. data/lib/vagrant-parallels/action/message_not_created.rb +0 -16
  32. data/lib/vagrant-parallels/action/message_not_running.rb +0 -16
  33. data/lib/vagrant-parallels/action/message_will_not_destroy.rb +0 -17
@@ -16,12 +16,12 @@ module VagrantPlugins
16
16
  end
17
17
 
18
18
  def read_settings
19
- vm = json { execute('list', @uuid, '--info', '--json', retryable: true) }
19
+ vm = json { execute_prlctl('list', @uuid, '--info', '--json') }
20
20
  vm.last
21
21
  end
22
22
 
23
23
  def read_state
24
- vm = json { execute('list', @uuid, '--json', retryable: true) }
24
+ vm = json { execute_prlctl('list', @uuid, '--json') }
25
25
  return nil if !vm.last
26
26
  vm.last.fetch('status').to_sym
27
27
  end
@@ -29,10 +29,10 @@ module VagrantPlugins
29
29
  def read_vms
30
30
  results = {}
31
31
  vms_arr = json([]) do
32
- execute('list', '--all', '--json', retryable: true)
32
+ execute_prlctl('list', '--all', '--json')
33
33
  end
34
34
  templates_arr = json([]) do
35
- execute('list', '--all', '--json', '--template', retryable: true)
35
+ execute_prlctl('list', '--all', '--json', '--template')
36
36
  end
37
37
  vms = vms_arr | templates_arr
38
38
  vms.each do |item|
@@ -45,17 +45,17 @@ module VagrantPlugins
45
45
  # Parse the JSON from *all* VMs and templates. Then return an array of objects (without duplicates)
46
46
  def read_vms_info
47
47
  vms_arr = json([]) do
48
- execute('list', '--all','--info', '--json', retryable: true)
48
+ execute_prlctl('list', '--all','--info', '--json')
49
49
  end
50
50
  templates_arr = json([]) do
51
- execute('list', '--all','--info', '--json', '--template', retryable: true)
51
+ execute_prlctl('list', '--all','--info', '--json', '--template')
52
52
  end
53
53
  vms_arr | templates_arr
54
54
  end
55
55
 
56
56
  def set_power_consumption_mode(optimized)
57
57
  state = optimized ? 'on' : 'off'
58
- execute('set', @uuid, '--longer-battery-life', state)
58
+ execute_prlctl('set', @uuid, '--longer-battery-life', state)
59
59
  end
60
60
  end
61
61
  end
@@ -15,8 +15,8 @@ module VagrantPlugins
15
15
  error_key(:mac_os_x_required)
16
16
  end
17
17
 
18
- class PrlCtlError < VagrantParallelsError
19
- error_key(:prlctl_error)
18
+ class ExecutionError < VagrantParallelsError
19
+ error_key(:execution_error)
20
20
  end
21
21
 
22
22
  class ParallelsInstallIncomplete < VagrantParallelsError
@@ -35,8 +35,12 @@ module VagrantPlugins
35
35
  error_key(:parallels_no_room_for_high_level_network)
36
36
  end
37
37
 
38
- class VMInaccessible < VagrantParallelsError
39
- error_key(:vm_inaccessible)
38
+ class ParallelsToolsIsoNotFound < VagrantParallelsError
39
+ error_key(:parallels_tools_iso_not_found)
40
+ end
41
+
42
+ class VMImportFailure < VagrantParallelsError
43
+ error_key(:vm_import_failure)
40
44
  end
41
45
 
42
46
  class VMNameExists < VagrantParallelsError
@@ -0,0 +1,53 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module GuestLinuxCap
4
+ class InstallParallelsTools
5
+
6
+ def self.install_parallels_tools(machine)
7
+ if ptiagent_usable?(machine)
8
+ # Argument '--info' means that Parallels Tools version will be
9
+ # checked before the installing.
10
+ machine.communicate.sudo("ptiagent-cmd --info")
11
+ else
12
+ machine.communicate.tap do |comm|
13
+ tools_iso_path = File.expand_path(
14
+ machine.provider.driver.read_guest_tools_iso_path("linux"),
15
+ machine.env.root_path
16
+ )
17
+ remote_file = "/tmp/prl-tools-lin.iso"
18
+ mount_point = "/media/prl-tools-lin_#{rand(100000)}/"
19
+
20
+ comm.upload(tools_iso_path, remote_file)
21
+
22
+ # Create mount point directory if needed
23
+ if !comm.test("test -d \"#{mount_point}\"", :sudo => true)
24
+ comm.sudo("mkdir -p \"#{mount_point}\"")
25
+ end
26
+
27
+ # Mount ISO and install Parallels Tools
28
+ comm.sudo("mount -o loop #{remote_file} #{mount_point}")
29
+ comm.sudo("#{mount_point}/install --install-unattended-with-deps")
30
+ comm.sudo("umount -f \"#{mount_point}\"")
31
+
32
+ comm.sudo("rm -Rf \"#{mount_point}\"")
33
+ comm.sudo("rm -f \"#{remote_file}\"")
34
+ end
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ # This helper detects is Parallels Tools Installation Agent (PTIAgent)
41
+ # available and can be used
42
+ def self.ptiagent_usable?(machine)
43
+ # Parallels Desktop 9 or higher should be installed on the host and
44
+ # 'ptiagent-cmd' binary should be available on the guest
45
+
46
+ machine.provider_name == :parallels &&
47
+ Gem::Version.new(machine.provider.driver.version) >= Gem::Version.new("9") &&
48
+ machine.communicate.test("which ptiagent-cmd", :sudo => true)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -45,11 +45,16 @@ module VagrantPlugins
45
45
  GuestLinuxCap::MountParallelsSharedFolder
46
46
  end
47
47
 
48
- guest_capability(:linux, :unmount_virtualbox_shared_folder) do
49
- require_relative "guest_cap/linux/mount_virtualbox_shared_folder"
48
+ guest_capability(:linux, :unmount_parallels_shared_folder) do
49
+ require_relative "guest_cap/linux/mount_parallels_shared_folder"
50
50
  GuestLinuxCap::MountParallelsSharedFolder
51
51
  end
52
52
 
53
+ guest_capability(:linux, :install_parallels_tools) do
54
+ require_relative "guest_cap/linux/install_parallels_tools"
55
+ GuestLinuxCap::InstallParallelsTools
56
+ end
57
+
53
58
  provider_capability(:parallels, :public_address) do
54
59
  require_relative "cap/public_address"
55
60
  Cap::PublicAddress
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.9.rc1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  en:
2
2
  vagrant_parallels:
3
3
  parallels:
4
- checking_guest_tools: |-
5
- Checking for Parallels Tools installed on the VM...
6
4
  power_consumption:
7
5
  set_mode: |-
8
6
  Setting power consumption mode: "%{mode}"
@@ -18,15 +16,14 @@ en:
18
16
  readable for the user that is running Vagrant.
19
17
 
20
18
  Parallels DHCP leases file: %{leases_file}
21
- mac_os_x_required: |-
22
- Parallels provider only works on OS X (or Mac OS X).
23
- prlctl_error: |-
24
- There was an error while executing `prlctl`, a CLI used by Vagrant
25
- for controlling Parallels Desktop. The command and stderr is shown below.
19
+ execution_error: |-
20
+ There was an error while command execution. The command and stderr is shown below.
26
21
 
27
22
  Command: %{command}
28
23
 
29
24
  Stderr: %{stderr}
25
+ mac_os_x_required: |-
26
+ Parallels provider works only on OS X (Mac OS X) systems.
30
27
  parallels_install_incomplete: |-
31
28
  Parallels Desktop is complaining that the installation is incomplete.
32
29
  Try to reinstall Parallels Desktop or contact Parallels support.
@@ -48,11 +45,16 @@ en:
48
45
  Vagrant uses the `prlctl` binary that ships with Parallels Desktop, and requires
49
46
  this to be available on the PATH. If Parallels Desktop is installed, please find
50
47
  the `prlctl` binary and add it to the PATH environmental variable.
51
- vm_inaccessible: |-
52
- Your VM has become "inaccessible." Unfortunately, this is a critical error
53
- with Parallels Desktop that Vagrant can not cleanly recover from.
54
- Please open VirtualBox and clear out your inaccessible virtual machines
55
- or find a way to fix them.
48
+ parallels_tools_iso_not_found: |-
49
+ Parallels Tools ISO file does not exists. The Parallels provider uses it
50
+ to install or update Parallels Tools in the guest machine. Try to
51
+ reinstall Parallels Desktop.
52
+
53
+ Expected ISO path: "%{iso_path}"
54
+ vm_import_failure: |-
55
+ The VM import failed! Please verify that the box you're using is not
56
+ corrupted and try again.
57
+
56
58
  vm_name_exists: |-
57
59
  Parallels Desktop virtual machine with the name '%{name}' already exists.
58
60
  Please use another name or delete the machine with the existing
@@ -101,23 +103,26 @@ en:
101
103
  #-------------------------------------------------------------------------------
102
104
  actions:
103
105
  vm:
104
- check_guest_tools:
106
+ handle_guest_tools:
107
+ cant_install: |-
108
+ Vagrant doesn't support installing Parallels Tools for the guest OS
109
+ running in the machine. Vagrant attempt to continue, assuming that
110
+ Parallels Tools will be installed later.
111
+ checking: |-
112
+ Checking for Parallels Tools installed on the VM...
113
+ installing: |-
114
+ Installing the proper version of Parallels Tools. This may take a few minutes...
105
115
  not_detected: |-
106
- No Parallels Tools were detected on the base box for this VM! Parallels
107
- Tools are required for forwarded ports, shared folders, host only
108
- networking, and more. If SSH fails on this machine, please install
109
- the Parallels Tools and repackage the box to continue.
110
-
111
- This is not an error message; everything may continue to work properly,
112
- in which case you may ignore this message.
113
- version_mismatch: |-
114
- The Parallels Tools on this VM do not match the installed version of
115
- Parallels Desktop! In most cases this is fine, but in rare cases it can
116
- cause things such as shared folders to not work properly. If you see
117
- shared folder errors, please update the Parallels Tools within the
118
- virtual machine and reload your VM.
119
-
120
- Parallels Tools Version: %{tools_version}
121
- Parallels Desktop Version: %{parallels_version}
116
+ Parallels Tools were not detected on this VM! They are required
117
+ for forwarded ports, shared folders, host only networking and more.
118
+ If SSH fails or shared folders are not working on this machine,
119
+ please install Parallels Tools within the virtual machine and
120
+ reload your VM.
121
+ outdated: |-
122
+ Parallels Tools installed on this VM are outdated! In most cases
123
+ this is fine but in rare cases it can cause things such as shared
124
+ folders to not work properly. If you see shared folder errors,
125
+ please update Parallels Tools within the virtual machine and
126
+ reload your VM.
122
127
  export:
123
128
  compacting: Compacting exported HDDs...
@@ -9,6 +9,7 @@ describe VagrantPlugins::Parallels::Driver::PD_8 do
9
9
  let(:tpl_uuid) {'1234-some-template-uuid-5678'}
10
10
  let(:tpl_name) {'Some_Template_Name'}
11
11
 
12
+ let(:tools_state) {'installed'}
12
13
  let(:tools_version) {'8.0.18615.123456'}
13
14
 
14
15
  let(:hostonly_iface) {'vnic10'}
@@ -75,6 +76,7 @@ INFO[
75
76
  "State": "stopped",
76
77
  "Home": "/path/to/#{vm_name}.pvm/",
77
78
  "GuestTools": {
79
+ "state": "#{tools_state}",
78
80
  "version": "#{tools_version}"
79
81
  },
80
82
  "Hardware": {
@@ -135,6 +137,7 @@ INFO[
135
137
  "State": "stopped",
136
138
  "Home": "/path/to/#{tpl_name}.pvm/",
137
139
  "GuestTools": {
140
+ "state": "#{tools_state}",
138
141
  "version": "#{tools_version}"
139
142
  },
140
143
  "Hardware": {
@@ -9,6 +9,7 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
9
9
  let(:tpl_uuid) {'1234-some-template-uuid-5678'}
10
10
  let(:tpl_name) {'Some_Template_Name'}
11
11
 
12
+ let(:tools_state) {'installed'}
12
13
  let(:tools_version) {'9.0.23062.123456'}
13
14
 
14
15
  let(:hostonly_iface) {'vnic10'}
@@ -75,6 +76,7 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
75
76
  "State": "stopped",
76
77
  "Home": "/path/to/#{vm_name}.pvm/",
77
78
  "GuestTools": {
79
+ "state": "#{tools_state}",
78
80
  "version": "#{tools_version}"
79
81
  },
80
82
  "Hardware": {
@@ -135,6 +137,7 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
135
137
  "State": "stopped",
136
138
  "Home": "/path/to/#{tpl_name}.pvm/",
137
139
  "GuestTools": {
140
+ "state": "#{tools_state}",
138
141
  "version": "#{tools_version}"
139
142
  },
140
143
  "Hardware": {
@@ -146,18 +146,16 @@ shared_examples "parallels desktop driver" do |options|
146
146
  end
147
147
  end
148
148
 
149
- describe "read_guest_tools_version" do
150
- let(:tools_version) {'9.0.23062.123456-something-else'}
149
+ describe "read_guest_tools_state" do
150
+ let(:tools_state) {'outdated'}
151
151
 
152
- it "returns Guest Tools version in semantic format: 'x.y.z'" do
153
- subject.read_guest_tools_version.should match(/^\d+.\d+\.\d+$/)
154
- subject.read_guest_tools_version.should == "9.0.23062"
152
+ it "returns Guest Tools state as a symbol" do
153
+ subject.read_guest_tools_state.should be(:outdated)
155
154
  end
156
155
 
157
- it "returns nil if Guest Tools version is invalid" do
158
- settings = {"GuestTools" => {"vesion" => "something_wrong"}}
159
- driver.should_receive(:read_settings).and_return(settings)
160
- subject.read_guest_tools_version.should be_nil
156
+ it "returns :not_installed if Guest Tools state can't be reached" do
157
+ driver.should_receive(:read_settings).and_return(exit_code: 0)
158
+ subject.read_guest_tools_state.should be(:not_installed)
161
159
  end
162
160
  end
163
161
 
@@ -181,6 +179,32 @@ shared_examples "parallels desktop driver" do |options|
181
179
  end
182
180
  end
183
181
 
182
+ describe "read_guest_tools_iso_path" do
183
+ before do
184
+ subprocess.stub(:execute).
185
+ with("mdfind", /^kMDItemCFBundleIdentifier ==/, an_instance_of(Hash)).
186
+ and_return(subprocess_result(stdout: "/Applications/Parallels Desktop.app"))
187
+ end
188
+
189
+ it "returns a valid path to the ISO" do
190
+ File.stub(:exist?).and_return(true)
191
+ iso_path = subject.read_guest_tools_iso_path("linux")
192
+ iso_path.should be_kind_of(String)
193
+ iso_path.should match(/prl-tools-lin\.iso$/)
194
+ end
195
+
196
+ it "raises an exception if ISO file does not exists" do
197
+ File.stub(:exist?).and_return(false)
198
+ expect { subject.read_guest_tools_iso_path("windows") }.
199
+ to raise_error(VagrantPlugins::Parallels::Errors::ParallelsToolsIsoNotFound)
200
+ end
201
+
202
+ it "returns nil if guest OS is unsupported or invalid" do
203
+ subject.read_guest_tools_iso_path("").should be_nil
204
+ subject.read_guest_tools_iso_path("bolgenos").should be_nil
205
+ end
206
+ end
207
+
184
208
  describe "read_mac_addresses" do
185
209
  it "returns MAC addresses of all network interface cards" do
186
210
  subject.read_mac_addresses.should be_kind_of(Hash)
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.9.rc1
4
+ version: 1.1.0
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-05-08 00:00:00.000000000 Z
12
+ date: 2014-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -98,26 +98,16 @@ files:
98
98
  - config/i18n-tasks.yml.erb
99
99
  - Gemfile
100
100
  - lib/vagrant-parallels/action/boot.rb
101
- - lib/vagrant-parallels/action/check_accessible.rb
102
- - lib/vagrant-parallels/action/check_created.rb
103
- - lib/vagrant-parallels/action/check_guest_tools.rb
104
- - lib/vagrant-parallels/action/check_parallels.rb
105
- - lib/vagrant-parallels/action/check_running.rb
106
101
  - lib/vagrant-parallels/action/clear_network_interfaces.rb
107
102
  - lib/vagrant-parallels/action/clear_shared_folders.rb
108
- - lib/vagrant-parallels/action/created.rb
109
103
  - lib/vagrant-parallels/action/customize.rb
110
104
  - lib/vagrant-parallels/action/destroy.rb
111
105
  - lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb
112
106
  - lib/vagrant-parallels/action/export.rb
113
107
  - lib/vagrant-parallels/action/forced_halt.rb
108
+ - lib/vagrant-parallels/action/handle_guest_tools.rb
114
109
  - lib/vagrant-parallels/action/import.rb
115
- - lib/vagrant-parallels/action/is_running.rb
116
- - lib/vagrant-parallels/action/is_suspended.rb
117
- - lib/vagrant-parallels/action/message_already_running.rb
118
- - lib/vagrant-parallels/action/message_not_created.rb
119
- - lib/vagrant-parallels/action/message_not_running.rb
120
- - lib/vagrant-parallels/action/message_will_not_destroy.rb
110
+ - lib/vagrant-parallels/action/is_driver_version.rb
121
111
  - lib/vagrant-parallels/action/network.rb
122
112
  - lib/vagrant-parallels/action/package.rb
123
113
  - lib/vagrant-parallels/action/package_config_files.rb
@@ -139,6 +129,7 @@ files:
139
129
  - lib/vagrant-parallels/driver/pd_9.rb
140
130
  - lib/vagrant-parallels/errors.rb
141
131
  - lib/vagrant-parallels/guest_cap/darwin/mount_parallels_shared_folder.rb
132
+ - lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
142
133
  - lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb
143
134
  - lib/vagrant-parallels/plugin.rb
144
135
  - lib/vagrant-parallels/provider.rb
@@ -1,23 +0,0 @@
1
- module VagrantPlugins
2
- module Parallels
3
- module Action
4
- class CheckAccessible
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- if env[:machine].state.id == :inaccessible
11
- # The VM we are attempting to manipulate is inaccessible. This
12
- # is a very bad situation and can only be fixed by the user. It
13
- # also prohibits us from actually doing anything with the virtual
14
- # machine, so we raise an error.
15
- raise VagrantPlugins::Parallels::Errors::VMInaccessible
16
- end
17
-
18
- @app.call(env)
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- module VagrantPlugins
2
- module Parallels
3
- module Action
4
- # This middleware checks that the VM is created, and raises an exception
5
- # if it is not, notifying the user that creation is required.
6
- class CheckCreated
7
- def initialize(app, env)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- if env[:machine].state.id == :not_created
13
- raise Vagrant::Errors::VMNotCreatedError
14
- end
15
-
16
- @app.call(env)
17
- end
18
- end
19
- end
20
- end
21
- end