From 2b780e1d8bcc5aebad591a831642712e1510ef48 Mon Sep 17 00:00:00 2001 From: Gray-Wind Date: Fri, 3 Jul 2015 17:44:18 +0300 Subject: [PATCH 01/12] Add linked clone to acceptance run --- tasks/acceptance.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/acceptance.rake b/tasks/acceptance.rake index 13abb4b6..c78f63aa 100644 --- a/tasks/acceptance.rake +++ b/tasks/acceptance.rake @@ -8,6 +8,7 @@ namespace :acceptance do task :run do components = %w( basic + linked_clone network/forwarded_port network/private_network synced_folder From 7ea018510af4468eb88d68e6d9231fcb3284e6c4 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Thu, 23 Jul 2015 10:16:59 +0300 Subject: [PATCH 02/12] docs: Fix compact command The virtual disk path should be specified with named argument "--hdd" Related to GH-200 --- website/docs/source/docs/boxes/base.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/docs/boxes/base.html.md b/website/docs/source/docs/boxes/base.html.md index f1296334..85b2f141 100755 --- a/website/docs/source/docs/boxes/base.html.md +++ b/website/docs/source/docs/boxes/base.html.md @@ -66,7 +66,7 @@ Prior to packaging up a box, you should shrink the hard drives as much as possible. This can be done with `prl_disk_tool`: ``` -$ prl_disk_tool compact /path/to/harddisk.hdd +$ prl_disk_tool compact --hdd /path/to/harddisk.hdd ``` ## Packaging From 9e8a948d8d3131d696d9e34aed0c67c20d27fedf Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 12 Aug 2015 20:33:27 +0300 Subject: [PATCH 03/12] Gemfile: Use Vagrant 1.7.4 for tests --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 46d66b71..62bf9e25 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,6 @@ group :development do # We depend on Vagrant for development, but we don't add it as a # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. - gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.2' + gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' gem 'vagrant-spec', git: 'git://github.com/mitchellh/vagrant-spec.git' end From b3d944cf795467dc74a3637219a094e0b3a81223 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 12 Aug 2015 20:41:36 +0300 Subject: [PATCH 04/12] test/acceptance: Use custom version of "vagrant-spec" gem Since https://github.com/mitchellh/vagrant-spec/issues/13 is fixed there, now we can get rid of "synced_folder" custom skeleton. --- Gemfile | 2 +- .../acceptance/provider/synced_folder_spec.rb | 26 ------------------- .../skeletons/synced_folder/Vagrantfile | 3 --- test/acceptance/skeletons/synced_folder/foo | 1 - 4 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 test/acceptance/provider/synced_folder_spec.rb delete mode 100644 test/acceptance/skeletons/synced_folder/Vagrantfile delete mode 100644 test/acceptance/skeletons/synced_folder/foo diff --git a/Gemfile b/Gemfile index 62bf9e25..8da6e0d8 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,5 @@ group :development do # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' - gem 'vagrant-spec', git: 'git://github.com/mitchellh/vagrant-spec.git' + gem 'vagrant-spec', git: 'git://github.com/legal90/vagrant-spec.git', branch: 'parallels' end diff --git a/test/acceptance/provider/synced_folder_spec.rb b/test/acceptance/provider/synced_folder_spec.rb deleted file mode 100644 index df28c1f4..00000000 --- a/test/acceptance/provider/synced_folder_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# This tests that synced folders work with a given provider. -shared_examples "provider/synced_folder" do |provider, options| - if !options[:box] - raise ArgumentError, - "box option must be specified for provider: #{provider}" - end - - include_context "acceptance" - - before do - environment.skeleton("synced_folder") - assert_execute("vagrant", "box", "add", "basic", options[:box]) - assert_execute("vagrant", "up", "--provider=#{provider}") - end - - after do - assert_execute("vagrant", "destroy", "--force") - end - - it "properly configures synced folder types" do - status("Test: mounts the default /vagrant synced folder") - result = execute("vagrant", "ssh", "-c", "cat /vagrant/foo") - expect(result.exit_code).to eql(0) - expect(result.stdout).to match(/hello$/) - end -end diff --git a/test/acceptance/skeletons/synced_folder/Vagrantfile b/test/acceptance/skeletons/synced_folder/Vagrantfile deleted file mode 100644 index 4b9dcc38..00000000 --- a/test/acceptance/skeletons/synced_folder/Vagrantfile +++ /dev/null @@ -1,3 +0,0 @@ -Vagrant.configure("2") do |config| - config.vm.box = "basic" -end diff --git a/test/acceptance/skeletons/synced_folder/foo b/test/acceptance/skeletons/synced_folder/foo deleted file mode 100644 index ce013625..00000000 --- a/test/acceptance/skeletons/synced_folder/foo +++ /dev/null @@ -1 +0,0 @@ -hello From 834be2e533e93ab1019849a766298e0add4edc78 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Tue, 18 Aug 2015 14:58:15 +0300 Subject: [PATCH 05/12] Change error for unsupported version of Parallels Desktop --- lib/vagrant-parallels/driver/meta.rb | 2 +- lib/vagrant-parallels/errors.rb | 4 ++++ locales/en.yml | 16 ++++++++++++---- test/unit/support/shared/pd_driver_examples.rb | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index 5f4825d7..23fa1ba0 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -51,7 +51,7 @@ def initialize(uuid=nil) if !driver_klass supported_versions = driver_map.keys.sort - raise VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion, + raise VagrantPlugins::Parallels::Errors::ParallelsUnsupportedVersion, supported_versions: supported_versions.join(", ") end diff --git a/lib/vagrant-parallels/errors.rb b/lib/vagrant-parallels/errors.rb index e790fb2e..86f50573 100644 --- a/lib/vagrant-parallels/errors.rb +++ b/lib/vagrant-parallels/errors.rb @@ -55,6 +55,10 @@ class ParallelsVMOptionNotFound < VagrantParallelsError error_key(:parallels_vm_option_not_found) end + class ParallelsUnsupportedVersion < VagrantParallelsError + error_key(:parallels_unsupported_version) + end + class SharedAdapterNotFound < VagrantParallelsError error_key(:shared_adapter_not_found) end diff --git a/locales/en.yml b/locales/en.yml index e1d4330b..ded62856 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -42,11 +42,10 @@ en: Parallels Desktop is complaining that the installation is incomplete. Try to reinstall Parallels Desktop or contact Parallels support. parallels_invalid_version: |- - Vagrant has detected that you have a version of Parallels Desktop installed - that is not supported. Please install or upgrade to one of the supported - versions listed below to use Vagrant: + Vagrant could not fetch Parallels Desktop version from output: + %{output} - %{supported_versions} + This is an internal error that should be reported as a bug. parallels_no_room_for_high_level_network: |- There is no available slots on the Parallels Desktop VM for the configured high-level network interfaces. "private_network" and "public_network" @@ -75,6 +74,15 @@ en: Could not find a required option of Parallels Desktop virtual machine: %{vm_option} This is an internal error that should be reported as a bug. + parallels_unsupported_version: |- + Vagrant has detected that you have a version of Parallels Desktop for Mac + installed that is not supported. Vagrant Parallels provider is compatible + only with Parallels Desktop 8 or later. + Please upgrade your installation: http://parallels.com/desktop + + Note: Starting since Parallels Desktop 11 for Mac, Vagrant Parallels + provider can be only used with Pro or Business edition of Parallels + Desktop for Mac. Please, be aware while choosing the edition to upgrade to. snapshot_id_not_detected: |- ID of the newly created shapshod could not be detected. This is an internal error that users should never see. Please report a bug. diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index c8d995db..a0327fd1 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -323,12 +323,12 @@ subject.version.should match(/^#{parallels_version}.\d+\.\d+$/) end - it "raises ParallelsInvalidVersion exception for unsupported version" do + it "raises an exception for unsupported version" do subprocess.should_receive(:execute). with("prlctl", "--version", an_instance_of(Hash)). and_return(subprocess_result(stdout: "prlctl version 7.0.12345")) expect { subject.version }. - to raise_error(VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion) + to raise_error(VagrantPlugins::Parallels::Errors::ParallelsUnsupportedVersion) end end end From 04a2de74595149b17060cf45e2776a5d30eabff6 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Tue, 18 Aug 2015 15:51:35 +0300 Subject: [PATCH 06/12] Raise an exception if Parallels Desktop version could not be fetched --- lib/vagrant-parallels/driver/meta.rb | 9 +++++---- test/unit/support/shared/pd_driver_examples.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index 23fa1ba0..6d8efb72 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -125,12 +125,13 @@ def read_version # * prlctl version 10.0.0 (12345) rev 123456 # # But we need exactly the first 3 numbers: "x.x.x" + output = execute(@prlctl_path, '--version') - if execute(@prlctl_path, '--version') =~ /prlctl version (\d+\.\d+.\d+)/ - return $1 + if output =~ /prlctl version (\d+\.\d+.\d+)/ + Regexp.last_match(1) + else + raise Errors::ParallelsInvalidVersion, output: output end - - nil end end end diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index a0327fd1..5cea090d 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -330,5 +330,13 @@ expect { subject.version }. to raise_error(VagrantPlugins::Parallels::Errors::ParallelsUnsupportedVersion) end + + it "raises an exception for invalid version output" do + subprocess.should_receive(:execute). + with("prlctl", "--version", an_instance_of(Hash)). + and_return(subprocess_result(stdout: "prlctl version 1.2.foo.bar")) + expect { subject.version }. + to raise_error(VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion) + end end end From 405b61742f89f89f2ed8d619f02ac4fdd54e8a40 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Tue, 18 Aug 2015 15:05:34 +0300 Subject: [PATCH 07/12] Refactor finding the appropriate driver class --- lib/vagrant-parallels/driver/meta.rb | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index 6d8efb72..a5878197 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -33,27 +33,15 @@ def initialize(uuid=nil) # Instantiate the proper version driver for Parallels Desktop @logger.debug("Finding driver for Parallels Desktop version: #{@version}") - driver_map = { - '8' => PD_8, - '9' => PD_9, - '10' => PD_10, - '11' => PD_11 - } - - driver_klass = nil - driver_map.each do |key, klass| - if @version.start_with?(key) - driver_klass = klass - break - end - end - - if !driver_klass - supported_versions = driver_map.keys.sort - raise VagrantPlugins::Parallels::Errors::ParallelsUnsupportedVersion, - supported_versions: supported_versions.join(", ") - end + driver_klass = + case @version.split('.').first + when '8' then PD_8 + when '9' then PD_9 + when '10' then PD_10 + when '11' then PD_11 + else raise Errors::ParallelsUnsupportedVersion + end @logger.info("Using Parallels driver: #{driver_klass}") @driver = driver_klass.new(@uuid) From d0b4637675f508ee8479161ad7035ba9bb678618 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Aug 2015 00:10:56 +0300 Subject: [PATCH 08/12] Add Parallels Desktop edition check In Parallels Desktop 11 and later the CLI is available only with Pro and Business editions. --- lib/vagrant-parallels/driver/meta.rb | 21 +++++++++++++++++++++ lib/vagrant-parallels/errors.rb | 4 ++++ locales/en.yml | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index a5878197..c4f5bedb 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -43,6 +43,15 @@ def initialize(uuid=nil) else raise Errors::ParallelsUnsupportedVersion end + # Starting since PD 11 only Pro and Business editions have CLI + # functionality and can be used with Vagrant. + if @version.split('.').first.to_i >= 11 + edition = read_edition + if !edition || !%w(any pro business).include?(edition) + raise Errors::ParallelsUnsupportedEdition + end + end + @logger.info("Using Parallels driver: #{driver_klass}") @driver = driver_klass.new(@uuid) @@ -102,6 +111,18 @@ def initialize(uuid=nil) protected + # Returns the edition of Parallels Desktop that is running. It makes + # sense only for Parallels Desktop 11 and later. For older versions + # it returns nil. + # + # @return [String] + def read_edition + lic_info = json({}) do + execute(@prlsrvctl_path, 'info', '--license', '--json') + end + lic_info['edition'] + end + # This returns the version of Parallels Desktop that is running. # # @return [String] diff --git a/lib/vagrant-parallels/errors.rb b/lib/vagrant-parallels/errors.rb index 86f50573..b658f3c7 100644 --- a/lib/vagrant-parallels/errors.rb +++ b/lib/vagrant-parallels/errors.rb @@ -55,6 +55,10 @@ class ParallelsVMOptionNotFound < VagrantParallelsError error_key(:parallels_vm_option_not_found) end + class ParallelsUnsupportedEdition < VagrantParallelsError + error_key(:parallels_unsupported_edition) + end + class ParallelsUnsupportedVersion < VagrantParallelsError error_key(:parallels_unsupported_version) end diff --git a/locales/en.yml b/locales/en.yml index ded62856..0ca78049 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -74,6 +74,13 @@ en: Could not find a required option of Parallels Desktop virtual machine: %{vm_option} This is an internal error that should be reported as a bug. + parallels_unsupported_edition: |- + Vagrant has detected that you have an edition of Parallels Desktop for Mac + installed that is not supported. Vagrant Parallels provider is compatible + only with Pro and Business editions of Parallels Desktop. Other editions + do not have command line functionality and can not be used with Vagrant. + + Please upgrade your installation: http://parallels.com/desktop parallels_unsupported_version: |- Vagrant has detected that you have a version of Parallels Desktop for Mac installed that is not supported. Vagrant Parallels provider is compatible From b6991a366e660cc1616a60c96dd24b99b1f61f1e Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Aug 2015 01:19:32 +0300 Subject: [PATCH 09/12] Add workaround for broken VM icons in the Dock After VM cloning it has a broken icon in the Dock. It is caused by the file "Icon\r" in the VM root. It appears in PD 11.0.0 and should be fixed in 11.0.1 --- lib/vagrant-parallels/action/import.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/vagrant-parallels/action/import.rb b/lib/vagrant-parallels/action/import.rb index 05486808..4d15a418 100644 --- a/lib/vagrant-parallels/action/import.rb +++ b/lib/vagrant-parallels/action/import.rb @@ -114,6 +114,13 @@ def import(env, tpl_name) @logger.info("Regenerate SourceVmUuid") @machine.provider.driver.regenerate_src_uuid end + + # Remove 'Icon\r' file from VM home (bug in PD 11.0.0) + if @machine.provider.pd_version_satisfies?('= 11.0.0') + vm_home = @machine.provider.driver.read_settings.fetch('Home') + broken_icns = Dir[File.join(vm_home, 'Icon*')] + FileUtils.rm(broken_icns, :force => true) + end end def snapshot_id(tpl_name) From 43e6b3880be07ff0ea0db44f02bb879257fa3ce8 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Aug 2015 10:08:43 +0300 Subject: [PATCH 10/12] Update copyright --- LICENSE.txt | 2 +- README.md | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 02fe1499..9ebf035e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ Copyright (c) 2013 Youssef Shahin -Copyright (c) 2013-2014 Parallels IP Holdings GmbH. +Copyright (c) 2013-2015 Parallels IP Holdings GmbH. MIT License diff --git a/README.md b/README.md index dc6af64c..57b69601 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,21 @@ Having problems while using the provider? Ask your question on the official foru If you get an error while using the Parallels provider or discover a bug, please report it on the [IssueTracker](https://github.com/Parallels/vagrant-parallels). -## Credits -Great thanks to *Youssef Shahin* `@yshahin` for having initiated the development -of this provider. You've done a great job, Youssef! +## License and Authors -Also, thanks to the people [who are contributing](https://github.com/Parallels/vagrant-parallels/graphs/contributors) - to our provider. +* Author: Youssef Shahin +* Author: Mikhail Zholobov +* Copyright 2013-2015, Parallels IP Holdings GmbH. +```text +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +``` From 32adc99afe42d868054ba9c1c5ea7c18fba4a70e Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Aug 2015 10:08:04 +0300 Subject: [PATCH 11/12] Update README according to Parallels Desktop 11 release --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 57b69601..d61320d0 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,25 @@ [![Code Climate](https://codeclimate.com/github/Parallels/vagrant-parallels.png)](https://codeclimate.com/github/Parallels/vagrant-parallels) This is a plugin for [Vagrant](http://www.vagrantup.com), -allowing to power [Parallels Desktop for Mac](http://www.parallels.com/downloads/desktop/) +allowing to power [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) based virtual machines. -### Requirements -- Parallels Desktop for Mac 8 or higher -- Vagrant v1.5 or higher - If you're just getting started with Vagrant, it is highly recommended that you read the official [Vagrant documentation](http://docs.vagrantup.com/v2/) first. -## Features -The Parallels provider supports all basic Vagrant features, but "Forwarded ports" - configuration is available only if you are using Parallels Desktop **10** for Mac. +### Requirements +- [Vagrant v1.5](http://www.vagrantup.com) or higher +- [Parallels Desktop 8 for Mac](http://www.parallels.com/products/desktop/) or higher + +**Attention for Parallels Desktop 11 users!** +This plugin is compatible only with *Pro* and *Business* editions of Parallels +Desktop 11. Standard edition doesn't have a command line functionality and can +not be used with Vagrant. + +## Features +The Parallels provider supports all basic Vagrant features, including shared folders, +private and public networks, forwarded ports and so on. ## Installation First, make sure that you have [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) From 123561143a60b2e2d0448446a8b6884e621b192e Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Aug 2015 10:27:36 +0300 Subject: [PATCH 12/12] Bump version to 1.4.2 --- lib/vagrant-parallels/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-parallels/version.rb b/lib/vagrant-parallels/version.rb index 0196c39a..968078eb 100644 --- a/lib/vagrant-parallels/version.rb +++ b/lib/vagrant-parallels/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Parallels - VERSION = '1.4.1' + VERSION = '1.4.2' end end