Skip to content

Commit

Permalink
Release v1.2.0.rc1
Browse files Browse the repository at this point in the history
Turned back an advanced synced folders for Linux, close to approach of VirtualBox provider:
  - Possibility to set mount options [GH-100] [GH-103]
  - Shared folders aren't missed after suspend/resume, [GH-102] is fixed
  - It is possible to share single folder to the some mount points, [GH-105] is fixed

Changes related to Parallels Desktop 10 Closed Beta:
  - Port Forwarding feature added. SSH sessions are working through the forwarded port by default.
  - All Password Restrictions will be disabled while the `vagrant up` [GH-67]

Bunch of refactoring
  • Loading branch information
legal90 committed Jul 8, 2014
2 parents 9f241ef + d4e8b5d commit 64e25e5
Show file tree
Hide file tree
Showing 37 changed files with 1,178 additions and 303 deletions.
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## How to contribute

We are glad you want to contribute to the `vagrant-parallels` plugin!
First of all, clone this repository:

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

### Dependencies and Unit Tests

To hack on our plugin, you'll need a [Ruby interpreter](https://www.ruby-lang.org/en/downloads/)
(>= 2.0) and [Bundler](http://bundler.io/) which can be installed with a simple
`gem install bundler`. Afterwards, do the following:

```
$ bundle install
$ rake
```

This will run the unit test suite, which should come back all green!
Then you're good to go!

If you want to run Vagrant without having to install the `vagrant-parallels`
gem, you may use `bundle exec`, like so:

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

### Building Provider from Source
To build a `vagrant-parallels` gem just run this command:

```
$ rake build
```

The built "gem" package will appear in the `./pkg` folder.

Then, if you want to install plugin from your locally built "gem", use the
following commands:

```
$ vagrant plugin uninstall vagrant-parallels
$ vagrant plugin install pkg/vagrant-parallels-<version>.gem
```

Now that you have your own plugin installed, check it with the command
`vagrant plugin list`

### Sending a Pull Request
If you're ready to send your changes, please follow the next steps:

1. Fork the 'vagrant-parallels' repository and ad it as a new remote (`git add
remote my-fork <fork_url>`)
2. Create a branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am "Added a sweet feature"`)
4. Push the branch to your fork (`git push fork my-new-feature`)
5. Create a pull request from your `my-new-feature` branch into `master` of
`vagrant-parallels` repo
59 changes: 2 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,64 +42,9 @@ We recommend you to start from these pages:
* [Getting Started](http://parallels.github.io/vagrant-parallels/docs/getting-started.html)
* [Boxes](http://parallels.github.io/vagrant-parallels/docs/boxes/index.html)

## Contributing to the Parallels Provider

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://bundler.io/) to get the dependencies (Ruby 2.0 is needed)
and rake to run the unit test suit:

```
$ bundle install
$ rake
```

If it passes successfully, you're ready to start developing the plugin. Use
bundler to execute Vagrant and test the plugin without installing:

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

### Building Provider from Source
To build a `vagrant-parallels` gem just run this command:

```
$ rake build
```

The built "gem" package will appear in the `./pkg` folder.

Then, if you want to install plugin from your locally built "gem", use the
following commands:

```
$ vagrant plugin uninstall vagrant-parallels
$ vagrant plugin install pkg/vagrant-parallels-<version>.gem
```

Now that you have your own plugin installed, check it with the command
`vagrant plugin list`

### Sending a Pull Request
If you're ready to send your changes, please follow the next steps:

1. Fork the 'vagrant-parallels' repository and ad it as a new remote (`git add
remote my-fork <fork_url>`)
2. Create a branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am "Added a sweet feature"`)
4. Push the branch to your fork (`git push fork my-new-feature`)
5. Create a pull request from your `my-new-feature` branch into `master` of
`vagrant-parallels` repo

## Getting Help
Having problems while using the provider? Ask your question to our mailing list:
[Google Group](https://groups.google.com/group/vagrant-parallels)
Having problems while using the provider? Ask your question on the official forum:
["Parallels Provider for Vagrant" forum branch](http://forum.parallels.com/forumdisplay.php?737-Parallels-Provider-for-Vagrant)

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).
Expand Down
23 changes: 16 additions & 7 deletions lib/vagrant-parallels/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ module Action
def self.action_boot
Vagrant::Action::Builder.new.tap do |b|
b.use SetName
b.use ClearForwardedPorts
b.use Provision
b.use EnvSet, port_collision_repair: true
b.use PrepareForwardedPortCollisionParams
b.use HandleForwardedPortCollisions
b.use PrepareNFSValidIds
b.use SyncedFolderCleanup
b.use SyncedFolders
b.use PrepareNFSSettings
b.use Network
b.use ClearNetworkInterfaces
b.use ForwardPorts
b.use SetHostname
b.use Call, IsDriverVersion, '>= 9' do |env1, b1|
if env1[:result]
b1.use SetPowerConsumption
end
end
b.use SaneDefaults
b.use Customize, "pre-boot"
b.use Boot
b.use Customize, "post-boot"
Expand Down Expand Up @@ -85,6 +86,8 @@ def self.action_halt
b2.use ForcedHalt
end
end

b1.use ClearForwardedPorts
end
end
end
Expand All @@ -101,6 +104,7 @@ def self.action_package

b1.use SetupPackageFiles
b1.use action_halt
b1.use ClearForwardedPorts
b1.use PrepareNFSValidIds
b1.use SyncedFolderCleanup
b1.use Package
Expand Down Expand Up @@ -161,6 +165,9 @@ def self.action_resume
next
end

b1.use EnvSet, port_collision_repair: false
b1.use PrepareForwardedPortCollisionParams
b1.use HandleForwardedPortCollisions
b1.use Resume
b1.use WaitForCommunicator, [:resuming, :running]
end
Expand Down Expand Up @@ -282,22 +289,24 @@ def self.action_up
autoload :Boot, File.expand_path("../action/boot", __FILE__)
autoload :HandleGuestTools, File.expand_path("../action/handle_guest_tools", __FILE__)
autoload :ClearNetworkInterfaces, File.expand_path("../action/clear_network_interfaces", __FILE__)
autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__)
autoload :Customize, File.expand_path("../action/customize", __FILE__)
autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__)
autoload :Export, File.expand_path("../action/export", __FILE__)
autoload :ForcedHalt, File.expand_path("../action/forced_halt", __FILE__)
autoload :ForwardPorts, File.expand_path("../action/forward_ports", __FILE__)
autoload :Import, File.expand_path("../action/import", __FILE__)
autoload :IsDriverVersion, File.expand_path("../action/is_driver_version", __FILE__)
autoload :Network, File.expand_path("../action/network", __FILE__)
autoload :Package, File.expand_path("../action/package", __FILE__)
autoload :PackageConfigFiles, File.expand_path("../action/package_config_files", __FILE__)
autoload :PrepareForwardedPortCollisionParams, File.expand_path("../action/prepare_forwarded_port_collision_params", __FILE__)
autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
autoload :PrepareNFSValidIds, File.expand_path("../action/prepare_nfs_valid_ids", __FILE__)
autoload :Resume, File.expand_path("../action/resume", __FILE__)
autoload :SaneDefaults, File.expand_path("../action/sane_defaults",__FILE__)
autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__)
autoload :SetName, File.expand_path("../action/set_name", __FILE__)
autoload :SetPowerConsumption, File.expand_path("../action/set_power_consumption", __FILE__)
autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
end
end
Expand Down
25 changes: 25 additions & 0 deletions lib/vagrant-parallels/action/clear_forwarded_ports.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module VagrantPlugins
module Parallels
module Action
class ClearForwardedPorts
def initialize(app, env)
@app = app
end

def call(env)
# Port Forwarding feature is available only with PD >= 10
if !env[:machine].provider.pd_version_satisfies?('>= 10')
return @app.call(env)
end

if !env[:machine].provider.driver.read_forwarded_ports.empty?
env[:ui].info I18n.t('vagrant.actions.vm.clear_forward_ports.deleting')
env[:machine].provider.driver.clear_forwarded_ports
end

@app.call(env)
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/vagrant-parallels/action/customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def call(env)
env[:machine].provider.driver.execute_prlctl(*processed_command)
rescue VagrantPlugins::Parallels::Errors::ExecutionError => e
raise Vagrant::Errors::VMCustomizationFailed, {
:command => command,
:error => e.inspect
command: command,
error: e.inspect
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Action
class Export
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::parallels::export")
@logger = Log4r::Logger.new('vagrant_parallels::action::export')
end

def call(env)
Expand Down
78 changes: 78 additions & 0 deletions lib/vagrant-parallels/action/forward_ports.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module VagrantPlugins
module Parallels
module Action
class ForwardPorts
include Util::CompileForwardedPorts

def initialize(app, env)
@app = app
end

#--------------------------------------------------------------
# Execution
#--------------------------------------------------------------
def call(env)
# Port Forwarding feature is available only with PD >= 10
if !env[:machine].provider.pd_version_satisfies?('>= 10')
return @app.call(env)
end

@env = env

# Get the ports we're forwarding
env[:forwarded_ports] ||= compile_forwarded_ports(env[:machine].config)
env[:ui].output(I18n.t('vagrant.actions.vm.forward_ports.forwarding'))
forward_ports

@app.call(env)
end

def forward_ports
ports = []

@env[:forwarded_ports].each do |fp|
message_attributes = {
guest_port: fp.guest_port,
host_port: fp.host_port
}

# Assuming the only reason to establish port forwarding is
# because the VM is using Shared networking. Host-only and
# bridged networking don't require port-forwarding and establishing
# forwarded ports on these attachment types has uncertain behaviour.
@env[:ui].detail(I18n.t("vagrant_parallels.actions.vm.forward_ports.forwarding_entry",
message_attributes))

# Add the options to the ports array to send to the driver later
ports << {
guestport: fp.guest_port,
hostport: fp.host_port,
name: get_unique_name(fp.id),
protocol: fp.protocol
}
end

if !ports.empty?
# We only need to forward ports if there are any to forward
@env[:machine].provider.driver.forward_ports(ports)
end
end

private

def get_unique_name(id)
all_rules = @env[:machine].provider.driver.read_forwarded_ports(true)
names_in_use = all_rules.collect { |r| r[:rule_name] }

# Append random suffix to get unique rule name
while names_in_use.include?(id)
suffix = (0...4).map { ('a'..'z').to_a[rand(26)] }.join
id = "#{id}_#{suffix}"
end

id
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/handle_guest_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Action
class HandleGuestTools
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::parallels::handle_guest_tools")
@logger = Log4r::Logger.new('vagrant_parallels::action::handle_guest_tools')
end

def call(env)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Action
class Import
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::parallels::import")
@logger = Log4r::Logger.new('vagrant_parallels::action::import')
end

def call(env)
Expand Down
28 changes: 0 additions & 28 deletions lib/vagrant-parallels/action/is_driver_version.rb

This file was deleted.

Loading

0 comments on commit 64e25e5

Please sign in to comment.