Skip to content

Commit

Permalink
Release v1.4.2
Browse files Browse the repository at this point in the history
* master:
  Bump version to 1.4.2
  Update README according to Parallels Desktop 11 release
  Update copyright
  Add workaround for broken VM icons in the Dock
  Add Parallels Desktop edition check
  Refactor finding the appropriate driver class
  Raise an exception if Parallels Desktop version could not be fetched
  Change error for unsupported version of Parallels Desktop
  test/acceptance: Use custom version of "vagrant-spec" gem
  Gemfile: Use Vagrant 1.7.4 for tests
  docs: Fix compact command
  Add linked clone to acceptance run
  • Loading branch information
legal90 committed Aug 19, 2015
2 parents a74accb + 1235611 commit 5ba8a61
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 75 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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 <[email protected]>
* Author: Mikhail Zholobov <[email protected]>
* 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
```
7 changes: 7 additions & 0 deletions lib/vagrant-parallels/action/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 32 additions & 22 deletions lib/vagrant-parallels/driver/meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lib/vagrant-parallels/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Parallels
VERSION = '1.4.1'
VERSION = '1.4.2'
end
end
23 changes: 19 additions & 4 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tasks/acceptance.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace :acceptance do
task :run do
components = %w(
basic
linked_clone
network/forwarded_port
network/private_network
synced_folder
Expand Down
26 changes: 0 additions & 26 deletions test/acceptance/provider/synced_folder_spec.rb

This file was deleted.

3 changes: 0 additions & 3 deletions test/acceptance/skeletons/synced_folder/Vagrantfile

This file was deleted.

1 change: 0 additions & 1 deletion test/acceptance/skeletons/synced_folder/foo

This file was deleted.

10 changes: 9 additions & 1 deletion test/unit/support/shared/pd_driver_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion website/docs/source/docs/boxes/base.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ba8a61

Please sign in to comment.