Skip to content

Commit

Permalink
Release 'v0.2.2'
Browse files Browse the repository at this point in the history
  Emit event for Upstart configs when shared folders are mounted [GH-88]
  update i18n-tasks to 0.3.9
  README.md: rewrited
  action/network refactoring.
  • Loading branch information
legal90 committed Mar 6, 2014
2 parents dd42041 + c023644 commit a6385c9
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 109 deletions.
135 changes: 89 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,94 @@
# Vagrant Parallels Provider
[![Gem Version](https://badge.fury.io/rb/vagrant-parallels.png)](http://badge.fury.io/rb/vagrant-parallels)
[![Build Status](https://travis-ci.org/Parallels/vagrant-parallels.png?branch=master)](https://travis-ci.org/Parallels/vagrant-parallels)
[![Code Climate](https://codeclimate.com/github/Parallels/vagrant-parallels.png)](https://codeclimate.com/github/Parallels/vagrant-parallels)

This is a [Vagrant](http://www.vagrantup.com) 1.3+ plugin that adds a [Parallels Desktop](http://www.parallels.com/products/desktop/)
provider to Vagrant, allowing Vagrant to control and provision machines using Parallels Desktop instead of the default Virtualbox.
This is a plugin for [Vagrant](http://www.vagrantup.com),
allowing to power virtual machines by
[Parallels Desktop for Mac](http://www.parallels.com/downloads/desktop/).

## Note
### Requirements
- Parallels Desktop for Mac 8 or 9
- Vagrant v1.4 or higher

This project is still in active development and not all vagrant features have been developed, so please report any issues you might find.
Almost all features are available except for exporting/packaging VM's. This will be available soon.
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.

We look forward to hearing from you with any issues or features. Thank you!
## Features
Parallels provider supports all basic Vagrant features, except one: **"Forwarded ports" configuration is not available yet**.

It might be implemented in the future, after the next release of Parallels Desktop for Mac.

## Installation
The latest version of this provider is supporting **only Vagrant 1.4 or higher**.
If you are still using Vagrant 1.3.*, please, specify the plugin version '0.0.9':
First of all make sure that you have [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/)
and [Vagrant](http://www.vagrantup.com/downloads) properly installed.
We recommend that you use the latest versions of these products.

Since Parallels provider is a Vagrant plugin, installing is easy:

- For Vagrant 1.4 or higher execute `vagrant plugin install vagrant-parallels`.
- For Vagrant 1.3.x execute `vagrant plugin install vagrant-parallels --plugin-version 0.0.9`.
```
$ vagrant plugin install vagrant-parallels
```

## Usage
After installing, then do a `vagrant up` and specify the `parallels` provider. An example is shown below.
Parallels provider is used just like any other provider. Please read the general
[basic usage](http://docs.vagrantup.com/v2/providers/basic_usage.html) page for
providers.

The value to use for the `--provider` flag is `parallels`:

```
$ vagrant init
$ vagrant up --provider=parallels
...
```

You need to have a parallels compatible box specified in your `Vagrantfile` before doing a `vagrant up`, please refer to the coming section for instructions.
You need to have a parallels compatible box specified in your `Vagrantfile`
before doing a `vagrant up`, please refer to the *Boxes* section for instructions.

### Default Provider

When using parallels as your vagrant provider after almost every command you will need to append `--provider=parallels`. To simplify this you can set your default vagrant provider as **parallels**

If you're using BASH
You can use `VAGRANT_DEFAULT_PROVIDER` environmental variable to specify the
default provider. Just set it to `parallels` and then it wont be necessary
to add `--provider` flag to vagrant commands.

```
# Append to bash
echo "export VAGRANT_DEFAULT_PROVIDER=parallels" | tee -a ~/.bashrc
source ~/.bashrc
export VAGRANT_DEFAULT_PROVIDER=parallels
```

If you're using ZSH
You can also add this command to your `~/.bashrc` file
(or `~/.zshrc` if your shell is Zsh) to make this setting permanent.

```
# Append to zsh
echo "export VAGRANT_DEFAULT_PROVIDER=parallels" | tee -a ~/.zshrc
source ~/.zshrc
```
## Boxes

Every provider in Vagrant must introduce a custom box format.

As with every provider, Parallels provider has a custom box format.
There is a list of popular base boxes for Parallels provider:

- Ubuntu 12.04 x86_64:
[http://download.parallels.com/desktop/vagrant/precise64.box]
(http://download.parallels.com/desktop/vagrant/precise64.box)

## Box Format
- Ubuntu 13.10 x86_64:
[http://download.parallels.com/desktop/vagrant/saucy64.box]
(http://download.parallels.com/desktop/vagrant/saucy64.box)

Every provider in Vagrant must introduce a custom box format. This
provider introduces `parallels` boxes. You can download one using this [link](http://download.parallels.com/desktop/vagrant/precise64.box).
- CentOS 6.5 x86_64:-
[http://download.parallels.com/desktop/vagrant/CentOS-6.5-x86_64.box]
(http://download.parallels.com/desktop/vagrant/CentOS-6.5-x86_64.box)

Download the box file, then use vagrant to add the downloaded box using this command. Remember to use `bundle exec` before `vagrant` command if you are in development mode
- CentOS 5.9 x86_64:-
[http://download.parallels.com/desktop/vagrant/CentOS-5.9-x86_64.box]
(http://download.parallels.com/desktop/vagrant/CentOS-5.9-x86_64.box)


You can add one of these boxes using the next command:

```
$ vagrant box add --provider=parallels precise64 http://download.parallels.com/desktop/vagrant/precise64.box
```

The box format is basically just the required `metadata.json` file
along with a `Vagrantfile` that does default settings for the
provider-specific configuration for this provider.

## Networking
By default Vagrant Parallels provider uses the basic Vagrant networking
approach. Initially VM has one adapter assigned to the 'Shared' network
Expand Down Expand Up @@ -114,14 +138,14 @@ end

## Development

To work on the `vagrant-parallels` plugin, clone this repository out
To work on the `vagrant-parallels` plugin development, clone this repository:

```
$ git clone https://github.com/Parallels/vagrant-parallels
$ cd vagrant-parallels
```

Use [Bundler](http://gembundler.com) to get the dependencies:
Use [Bundler](http://gembundler.com) to get the dependencies (Ruby 2.0 is needed):

```
$ bundle
Expand All @@ -135,44 +159,63 @@ $ bundle exec rake

If those pass, you're ready to start developing the plugin. You can test
the plugin without installing it into your Vagrant environment by just
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
creating a `Vagrantfile` in the top level of this directory (it is added to *.gitignore*)
and add the following line to your `Vagrantfile`

```ruby
Vagrant.require_plugin "vagrant-parallels"
```

You need to have a compatible box file installed, refer to box file section
You need to have a compatible box file installed, refer to the *Boxes* section

Use bundler to execute Vagrant:

```
$ bundle exec vagrant up --provider=parallels
```

After testing you can also build a gem-package by yourself and then install it as a plugin:
(if you have 'vagrant-parallels' plugin already installed, delete it first)
###Installing Parallels Provider From Source

If you want to globally install your locally built plugin from source, use the following method:

```
$ git clone https://github.com/Parallels/vagrant-parallels
$ cd vagrant-parallels
$ rake build
$ bundle install
...
$ vagrant plugin install ./pkg/vagrant-parallels-<version>.gem
$ bundle exec rake build
...
$ vagrant plugin install pkg/vagrant-parallels-<version>.gem
...
```
So, now that you have your own plugin installed, check it with the command `vagrant plugin list`
So, now that you have your own plugin installed, check it with the command
`vagrant plugin list`

## Contributing

1. Fork it.
2. Create a branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am "Added a sweet feature"`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a pull request from your `my-new-feature` branch into master

## Getting help
Having problems while using our provider? Ask your question to our mailing list:
[Google Group](https://groups.google.com/group/vagrant-parallels)

If you've got a strange error while using Parallels provider, or found a bug
there - please, report it on [Issue Tracker](https://github.com/Parallels/vagrant-parallels).

## Contributors
## Credits
Great thanks to *Youssef Shahin* `@yshahin` for having initiated the development
of this provider. You've done a great job, Youssef!

A great thanks to the people who helping this project stand on its feet, thank you
Also, thanks to the people who helping this project stand on its feet, thank you

* Youssef Shahin `@yshahin` - plugin's author
* Mikhail Zholobov `@legal90`
* Kevin Kaland `@wizonesolutions`
* Konstantin Nazarov `@racktear`
* Dmytro Vasylenko `@odi-um`
* Thomas Koschate `@koschate`

and to all the people who are using and testing this provider
and to all the people who are using and testing this provider.

3 changes: 0 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'

#Load i18-tasks
load 'tasks/i18n-tasks.rake'

# Immediately sync all stdout so that tools like buildbot can
# immediately load in the output.
$stdout.sync = true
Expand Down
18 changes: 8 additions & 10 deletions lib/vagrant-parallels/action/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def bridged_adapter(config)

# Search for a matching bridged interface
bridgedifs.each do |interface|
if [interface[:name].downcase, interface[:bound_to]].include? config[:bridge].downcase
if interface[:name].downcase == config[:bridge].downcase
@logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.")
chosen_bridge = interface
chosen_bridge = interface[:name]
break
end
end
Expand All @@ -174,7 +174,7 @@ def bridged_adapter(config)
if !chosen_bridge
if bridgedifs.length == 1
# One bridgable interface? Just use it.
chosen_bridge = bridgedifs[0]
chosen_bridge = bridgedifs[0][:name]
@logger.debug("Only one bridged interface available. Using it by default.")
else
# More than one bridgable interface requires a user decision, so
Expand All @@ -196,18 +196,17 @@ def bridged_adapter(config)
choice = choice.to_i
end

chosen_bridge = bridgedifs[choice - 1]
chosen_bridge = bridgedifs[choice - 1][:name]
end
end

@logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge[:name]} (#{chosen_bridge[:bound_to]})")
@logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge}")

# Given the choice we can now define the adapter we're using
return {
:adapter => config[:adapter],
:type => :bridged,
:bridge => chosen_bridge[:name],
:bound_to => chosen_bridge[:bound_to],
:bridge => chosen_bridge,
:mac_address => config[:mac],
:nic_type => config[:nic_type]
}
Expand Down Expand Up @@ -321,7 +320,6 @@ def hostonly_adapter(config)
return {
:adapter => config[:adapter],
:hostonly => interface[:name],
:bound_to => interface[:bound_to],
:mac => config[:mac],
:nic_type => config[:nic_type],
:type => :hostonly
Expand Down Expand Up @@ -392,7 +390,7 @@ def assign_interface_numbers(networks, adapters)
end

# This determines the next free network name
def next_network_name
def next_network_id
# Get the list of numbers
net_nums = []
@env[:machine].provider.driver.read_virtual_networks.each do |net|
Expand All @@ -416,7 +414,7 @@ def next_network_name
# This creates a host only network for the given configuration.
def hostonly_create_network(config)
options = {
:name => next_network_name,
:network_id => next_network_id,
:adapter_ip => config[:adapter_ip],
:netmask => config[:netmask],
}
Expand Down
27 changes: 12 additions & 15 deletions lib/vagrant-parallels/driver/pd_8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def clear_shared_folders

def create_host_only_network(options)
# Create the interface
execute(:prlsrvctl, "net", "add", options[:name], "--type", "host-only")
execute(:prlsrvctl, "net", "add", options[:network_id], "--type", "host-only")

# Configure it
args = ["--ip", "#{options[:adapter_ip]}/#{options[:netmask]}"]
Expand All @@ -51,16 +51,15 @@ def create_host_only_network(options)
"--ip-scope-end", options[:dhcp][:upper]])
end

execute(:prlsrvctl, "net", "set", options[:name], *args)
execute(:prlsrvctl, "net", "set", options[:network_id], *args)

# Determine interface to which it has been bound
net_info = json { execute(:prlsrvctl, 'net', 'info', options[:name], '--json', retryable: true) }
bound_to = net_info['Bound To']
net_info = json { execute(:prlsrvctl, 'net', 'info', options[:network_id], '--json', retryable: true) }
iface_name = net_info['Bound To']

# Return the details
return {
:name => options[:name],
:bound_to => bound_to,
:name => iface_name,
:ip => options[:adapter_ip],
:netmask => options[:netmask],
:dhcp => options[:dhcp]
Expand Down Expand Up @@ -123,15 +122,15 @@ def enable_adapters(adapters)
args.concat(["--device-add", "net"])
end

if adapter[:hostonly] or adapter[:bridge]
if adapter[:type] == :hostonly
# Oddly enough, but there is a 'bridge' anyway.
# The only difference is the destination interface:
# - in host-only (private) network it will be bridged to the 'vnicX' device
# - in real bridge (public) network it will be bridged to the assigned device
args.concat(["--type", "bridged", "--iface", adapter[:bound_to]])
end

if adapter[:type] == :shared
args.concat(["--type", "bridged", "--iface", adapter[:hostonly]])
elsif adapter[:type] == :bridge
args.concat(["--type", "bridged", "--iface", adapter[:bridge]])
elsif adapter[:type] == :shared
args.concat(["--type", "shared"])
end

Expand Down Expand Up @@ -199,8 +198,7 @@ def read_bridged_interfaces
info = {}
ifconfig = execute(:ifconfig, iface['Bound To'])
# Assign default values
info[:name] = iface['Network ID'].gsub(/\s\(.*?\)$/, '')
info[:bound_to] = iface['Bound To']
info[:name] = iface['Bound To']
info[:ip] = "0.0.0.0"
info[:netmask] = "0.0.0.0"
info[:status] = "Down"
Expand Down Expand Up @@ -235,8 +233,7 @@ def read_host_only_interfaces
info = {}
net_info = json { execute(:prlsrvctl, 'net', 'info', iface['Network ID'], '--json') }
# Really we need to work with bounded virtual interface
info[:name] = net_info['Network ID']
info[:bound_to] = net_info['Bound To']
info[:name] = net_info['Bound To']
info[:ip] = net_info['Parallels adapter']['IP address']
info[:netmask] = net_info['Parallels adapter']['Subnet mask']
# Such interfaces are always in 'Up'
Expand Down
Loading

0 comments on commit a6385c9

Please sign in to comment.