diff --git a/Gemfile b/Gemfile index 46d66b71..8da6e0d8 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-spec', git: 'git://github.com/mitchellh/vagrant-spec.git' + gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' + gem 'vagrant-spec', git: 'git://github.com/legal90/vagrant-spec.git', branch: 'parallels' end 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..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/) @@ -47,10 +52,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 + +* Author: Youssef Shahin +* Author: Mikhail Zholobov +* Copyright 2013-2015, Parallels IP Holdings GmbH. -Also, thanks to the people [who are contributing](https://github.com/Parallels/vagrant-parallels/graphs/contributors) - to our provider. +```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 +``` 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) diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index 5f4825d7..c4f5bedb 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -33,26 +33,23 @@ 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 + 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 - raise VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion, - supported_versions: supported_versions.join(", ") + # 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}") @@ -114,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] @@ -125,12 +134,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/lib/vagrant-parallels/errors.rb b/lib/vagrant-parallels/errors.rb index e790fb2e..b658f3c7 100644 --- a/lib/vagrant-parallels/errors.rb +++ b/lib/vagrant-parallels/errors.rb @@ -55,6 +55,14 @@ 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 + class SharedAdapterNotFound < VagrantParallelsError error_key(:shared_adapter_not_found) end 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 diff --git a/locales/en.yml b/locales/en.yml index e1d4330b..0ca78049 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,22 @@ 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 + 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/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 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 diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index c8d995db..5cea090d 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -323,10 +323,18 @@ 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::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 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