Skip to content

Commit

Permalink
Release v0.2.2.rc1
Browse files Browse the repository at this point in the history
[x] Fixed network adapter configuration issue if using provider-specific config [hashicorp/vagrant#2854]
[x] Fixed error "dhclient is already running" [GH-83]
[x] Fixed error "VM Boot Timeout" [GH-58]
[x] Added possibility to skip guest tools check
[x] Added interrupt handling in import/export actions [GH-36]
[x] Deprecated Vagrantfile in boxes. Base MAC is not required [GH-79]
  • Loading branch information
legal90 committed Mar 2, 2014
2 parents 4d15741 + 078f58a commit dd42041
Show file tree
Hide file tree
Showing 39 changed files with 2,069 additions and 830 deletions.
34 changes: 21 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# OS-specific
.DS_Store

#rbenv
.ruby-version
# Vagrant stuff
acceptance_config.yml
boxes/*
/Vagrantfile
/.vagrant
/vagrant-spec.config.rb

# Bundler/Rubygems
*.gem
.bundle
pkg/*
tags
Gemfile.lock
/Gemfile.lock
test/tmp/

# Vagrant

# Vagrant stuff
acceptance_config.yml
boxes/*
Vagrantfile
.vagrant
vagrant-spec.config.rb
*.box
# Python
*.pyc
sandi_meter

# Rubinius
*.rbc

# IDE junk
.idea/*
*.iml

# Ruby Managers
.rbenv
.ruby-gemset
.ruby-version
.rvmrc
115 changes: 41 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,60 +66,50 @@ along with a `Vagrantfile` that does default settings for the
provider-specific configuration for this provider.

## Networking
By default 'vagrant-parallels' uses the basic Vagrant networking approach. By default VM has one adapter assigned to the 'Shared' network in Parallels Desktop.
But you can also add one ore more `:private_network` adapters, as described below:

### Private Network
It is fully compatible with basic Vagrant [Private Networks](http://docs.vagrantup.com/v2/networking/private_network.html).
#### Available arguments:
- `type` - IP configuration way: `:static` or `:dhcp` (exactly Symbol object). Default is `:static`. If `:dchp` is set, such interface will get an IP dynamically from default subnet "10.37.129.1/255.255.255.0".
- `mac` - MAC address which will be assigned to this network adapter. If omitted, MAC will be automatically generated at the first `up` of VM.
- `ip` - IP address which will be assigned to this network adapter. It is required only if type is `:static`.
- `netmask` - network mask. Default is `"255.255.255.0"`. It is required only if type is `:static`.
- `nic_type` - Unnecessary argument, means the type of network adapter. Can be any of `"virtio"`, `"e1000"` or `"rtl"`. Default is `"e1000"`.

#### Example:
```ruby
Vagrant.configure("2") do |config|
config.vm.network :private_network, ip: "33.33.33.50", netmask: "255.255.0.0"
config.vm.network :private_network, type: :dhcp, nic_type: "rtl"
end
```
It means that two private network adapters will be configured:
1) The first will have static ip '33.33.33.50' and mask '255.255.0.0'. It will be represented as device `"e1000"` by default (e.g. 'Intel(R) PRO/1000 MT').
2) The second adapter will be configured as `"rtl"` ('Realtek RTL8029AS') and get an IP from internal DHCP server, which is working on the default network "10.37.129.1/255.255.255.0".

### Public Network
It is fully compatible with basic Vagrant [Public Networks](http://docs.vagrantup.com/v2/networking/public_network.html).
#### Available arguments (unnecessary, but provider specific):
- `bridge` - target host's interface for bridged network. You can specify full (ex: `Wi-Fi`) or short (ex: `en0`) name of interface. If omitted, you will be asked to choose the interface during the VM boot (or if only one interface exists, it will be chosen automatically).
_Hint:_ Full names of network interfaces are displayed in _System Preferences -> Network_ window, and short names - in the `ifconfig` command output on your Mac.
- `mac` - MAC address which will be assigned to this network adapter. If omitted, MAC will be automatically generated at the first `up` of VM.
- `ip` - IP address which will be assigned to this network adapter. Use it, if you want to configure adapter manually.
- `netmask` - network mask. Default is `"255.255.255.0"`. It is used only in pair with `ip`
- `type` - IP configuration way, only `:dhcp` is available. Use it only if your public network has a valid DHCP server. Otherwise, omit this attribute or use an `ip` and `netmask` described above.
- `nic_type` - type of network adapter. Can be any of `"virtio"`, `"e1000"` or `"rtl"`. Default is `"e1000"`.

#### Example:
By default Vagrant Parallels provider uses the basic Vagrant networking
approach. Initially VM has one adapter assigned to the 'Shared' network
in Parallels Desktop.

But you can also add `:private_network` and `:public_network` adapters.
These features are working by the same way as in the basic Vagrant:
- [Private Networks]
(http://docs.vagrantup.com/v2/networking/private_network.html)
- [Public Networks]
(http://docs.vagrantup.com/v2/networking/public_network.html)

## Provider Specific Configuration

Parallels Desktop has a `prlctl` utility that can be used to make modifications
to Parallels virtual machines from the command line.


Parallels provider exposes a way to call any command against *prlctl* just prior
to booting the machine:

```ruby
Vagrant.configure("2") do |config|
config.vm.network :public_network, bridge: "Wi-Fi", mac: "001C425FC3AB", type: :dhcp
config.vm.network :public_network, bridge: "en4", ip: "10.3.1.18", netmask: "255.255.252.0"
config.vm.provider "parallels" do |v|
v.customize ["set", :id, "--device-set", "cdrom0", "--image",
"/path/to/disk.iso", "--connect"]
end
```
It means that two public network adapters will be configured:
1) The first will be bridged to the 'Wi-Fi' host machine's interface and will have the specified MAC address. After the VM boot it will be automatically configured to get an IP from the DHCP server, which is accessible in the 'Wi-Fi' network).
2) The second adapter will be bridged to the interface 'en4' and will have static ip '10.3.1.18' and mask '255.255.252.0'.

## Provider Specific Configuration
In the example above, the VM is modified to have a specified iso image attached
to it's virtual media device (cdrom). Some details:

Provider allows to define directives for `prlctl set` through `Vagrantfile` in same way as this done in VirtualBox provider.
* The `:id` special parameter is replaced with the ID of the virtual
machine being created, so when a *prlctl* command requires an ID, you
can pass this special parameter.

* Multiple `customize` directives can be used. They will be executed in the
order given.

There are some convenience shortcuts for memory and CPU settings:

#### Example:
```ruby
config.vm.provider :parallels do |parallels|
parallels.name = "HipHop VM"
parallels.customize ["set", :id, "--memsize", "1024"]
config.vm.provider "parallels" do |v|
v.memory = 1024
v.cpus = 2
end
```

## Development
Expand Down Expand Up @@ -177,35 +167,12 @@ So, now that you have your own plugin installed, check it with the command `vagr

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

* Kevin Kaland `@wizonesolutions`
* 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 tool

## Copyright & license

The MIT License (MIT)

Copyright (c) 2014 Youssef Shahin

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
and to all the people who are using and testing this provider

2 changes: 1 addition & 1 deletion config/i18n-tasks.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ search:
paths:
- "lib/"
data:
adapter: yaml
adapter: file_system
read:
- "locales/%{locale}.yml"
- "<%= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
Expand Down
7 changes: 0 additions & 7 deletions lib/vagrant-parallels/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,8 @@ def self.action_up
# If the VM is NOT created yet, then do the setup steps
if !env[:result]
b2.use CheckAccessible
b2.use RegisterTemplate
b2.use Customize, "pre-import"
b2.use Import
b2.use UnregisterTemplate
b2.use MatchMACAddress
end
end
b.use action_start
Expand All @@ -288,7 +285,6 @@ def self.action_up
autoload :Import, File.expand_path("../action/import", __FILE__)
autoload :IsSuspended, File.expand_path("../action/is_suspended", __FILE__)
autoload :IsRunning, File.expand_path("../action/is_running", __FILE__)
autoload :MatchMACAddress, File.expand_path("../action/match_mac_address", __FILE__)
autoload :MessageAlreadyRunning, File.expand_path("../action/message_already_running", __FILE__)
autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__)
autoload :MessageNotRunning, File.expand_path("../action/message_not_running", __FILE__)
Expand All @@ -298,13 +294,10 @@ def self.action_up
autoload :PackageConfigFiles, File.expand_path("../action/package_config_files", __FILE__)
autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
autoload :PrepareNFSValidIds, File.expand_path("../action/prepare_nfs_valid_ids", __FILE__)
autoload :RegisterTemplate, File.expand_path("../action/register_template", __FILE__)
autoload :Resume, File.expand_path("../action/resume", __FILE__)
autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__)
autoload :SetName, File.expand_path("../action/set_name", __FILE__)
autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
autoload :UnregisterTemplate, File.expand_path("../action/unregister_template", __FILE__)

end
end
end
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/check_accessible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call(env)
# is a very bad situation and can only be fixed by the user. It
# also prohibits us from actually doing anything with the virtual
# machine, so we raise an error.
raise Vagrant::Errors::VMInaccessible
raise VagrantPlugins::Parallels::Errors::VMInaccessible
end

@app.call(env)
Expand Down
12 changes: 10 additions & 2 deletions lib/vagrant-parallels/action/check_guest_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ module Action
class CheckGuestTools
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::parallels::check_guest_tools")
end

def call(env)
if !env[:machine].provider_config.check_guest_tools
@logger.info("Not checking guest tools because configuration")
return @app.call(env)
end

env[:ui].info(I18n.t("vagrant_parallels.parallels.checking_guest_tools"))

tools_version = env[:machine].provider.driver.read_guest_tools_version
if !tools_version
env[:ui].warn I18n.t("vagrant_parallels.actions.vm.check_guest_tools.not_detected")
else
pd_version = env[:machine].provider.driver.version
unless pd_version.start_with? tools_version
env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.check_guest_tools.version_mismatch",
tools_version: tools_version,
parallels_version: pd_version))
:tools_version => tools_version,
:parallels_version => pd_version))
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/clear_network_interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(app, env)
def call(env)
# Delete all disabled network adapters
env[:ui].info I18n.t("vagrant.actions.vm.clear_network_interfaces.deleting")
env[:machine].provider.driver.delete_adapters
env[:machine].provider.driver.delete_disabled_adapters

@app.call(env)
end
Expand Down
10 changes: 6 additions & 4 deletions lib/vagrant-parallels/action/customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def call(env)
arg.to_s
end

result = env[:machine].provider.driver.set_vm_settings(processed_command)
if result.exit_code != 0
begin
env[:machine].provider.driver.execute_command(
processed_command + [retryable: true])
rescue VagrantPlugins::Parallels::Errors::PrlCtlError => e
raise Vagrant::Errors::VMCustomizationFailed, {
:command => processed_command.inspect,
:error => result.stderr
:command => command,
:error => e.inspect
}
end
end
Expand Down
Loading

0 comments on commit dd42041

Please sign in to comment.