-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
37 changed files
with
1,178 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.