vagrant-parallels 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -2
- data/lib/vagrant-parallels/action/network.rb +89 -0
- data/lib/vagrant-parallels/driver/prl_ctl.rb +15 -12
- data/lib/vagrant-parallels/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -65,9 +65,10 @@ By default 'vagrant-parallels' uses the basic Vagrant networking approach. By de
|
|
65
65
|
But you can also add one ore more `:private_network` adapters, as described below:
|
66
66
|
|
67
67
|
### Private Network
|
68
|
-
It is fully compatible with basic Vagrant [Private
|
68
|
+
It is fully compatible with basic Vagrant [Private Networks](http://docs.vagrantup.com/v2/networking/private_network.html).
|
69
69
|
#### Available arguments:
|
70
|
-
- `type` - IP configuration way: `:static` or `:dhcp
|
70
|
+
- `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".
|
71
|
+
- `mac` - MAC address which will be assigned to this network adapter. If omitted, MAC will be automatically generated at the first `up` of VM.
|
71
72
|
- `ip` - IP address which will be assigned to this network adapter. It is required only if type is `:static`.
|
72
73
|
- `netmask` - network mask. Default is `"255.255.255.0"`. It is required only if type is `:static`.
|
73
74
|
- `nic_type` - Unnecessary argument, means the type of network adapter. Can be any of `"virtio"`, `"e1000"` or `"rtl"`. Default is `"e1000"`.
|
@@ -83,6 +84,28 @@ It means that two private network adapters will be configured:
|
|
83
84
|
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').
|
84
85
|
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".
|
85
86
|
|
87
|
+
### Public Network
|
88
|
+
It is fully compatible with basic Vagrant [Public Networks](http://docs.vagrantup.com/v2/networking/public_network.html).
|
89
|
+
#### Available arguments (unnecessary, but provider specific):
|
90
|
+
- `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).
|
91
|
+
_Hint:_ Full names of network interfaces are displayed in _System Preferences -> Network_ window, and short names - in the `ifconfig` command output on your Mac.
|
92
|
+
- `mac` - MAC address which will be assigned to this network adapter. If omitted, MAC will be automatically generated at the first `up` of VM.
|
93
|
+
- `ip` - IP address which will be assigned to this network adapter. Use it, if you want to configure adapter manually.
|
94
|
+
- `netmask` - network mask. Default is `"255.255.255.0"`. It is used only in pair with `ip`
|
95
|
+
- `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.
|
96
|
+
- `nic_type` - type of network adapter. Can be any of `"virtio"`, `"e1000"` or `"rtl"`. Default is `"e1000"`.
|
97
|
+
|
98
|
+
#### Example:
|
99
|
+
```ruby
|
100
|
+
Vagrant.configure("2") do |config|
|
101
|
+
config.vm.network :public_network, bridge: "Wi-Fi", mac: "001C425FC3AB", type: :dhcp
|
102
|
+
config.vm.network :public_network, bridge: "en4", ip: "10.3.1.18", netmask: "255.255.252.0"
|
103
|
+
end
|
104
|
+
```
|
105
|
+
It means that two public network adapters will be configured:
|
106
|
+
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).
|
107
|
+
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'.
|
108
|
+
|
86
109
|
## Development
|
87
110
|
|
88
111
|
To work on the `vagrant-parallels` plugin, clone this repository out
|
@@ -98,6 +98,95 @@ module VagrantPlugins
|
|
98
98
|
|
99
99
|
end
|
100
100
|
|
101
|
+
def bridged_config(options)
|
102
|
+
if options[:type] and options[:type].to_sym == :dhcp
|
103
|
+
options[:dhcp] = true
|
104
|
+
end
|
105
|
+
|
106
|
+
return {
|
107
|
+
:bridge => nil,
|
108
|
+
:mac => nil,
|
109
|
+
:nic_type => "e1000",
|
110
|
+
}.merge(options || {})
|
111
|
+
end
|
112
|
+
|
113
|
+
def bridged_adapter(config)
|
114
|
+
# Find the bridged interfaces that are available
|
115
|
+
bridgedifs = @env[:machine].provider.driver.read_bridged_interfaces
|
116
|
+
bridgedifs.delete_if { |interface| interface[:status] == "Down" }
|
117
|
+
|
118
|
+
# The name of the chosen bridge interface will be assigned to this
|
119
|
+
# variable.
|
120
|
+
chosen_bridge = nil
|
121
|
+
|
122
|
+
if config[:bridge]
|
123
|
+
@logger.debug("Bridge was directly specified in config, searching for: #{config[:bridge]}")
|
124
|
+
|
125
|
+
# Search for a matching bridged interface
|
126
|
+
bridgedifs.each do |interface|
|
127
|
+
if [interface[:name].downcase, interface[:bound_to]].include? config[:bridge].downcase
|
128
|
+
@logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.")
|
129
|
+
chosen_bridge = interface
|
130
|
+
break
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# If one wasn't found, then we notify the user here.
|
135
|
+
if !chosen_bridge
|
136
|
+
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.specific_not_found",
|
137
|
+
:bridge => config[:bridge])
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# If we still don't have a bridge chosen (this means that one wasn't
|
142
|
+
# specified in the Vagrantfile, or the bridge specified in the Vagrantfile
|
143
|
+
# wasn't found), then we fall back to the normal means of searching for a
|
144
|
+
# bridged network.
|
145
|
+
if !chosen_bridge
|
146
|
+
if bridgedifs.length == 1
|
147
|
+
# One bridgable interface? Just use it.
|
148
|
+
chosen_bridge = bridgedifs[0]
|
149
|
+
@logger.debug("Only one bridged interface available. Using it by default.")
|
150
|
+
else
|
151
|
+
# More than one bridgable interface requires a user decision, so
|
152
|
+
# show options to choose from.
|
153
|
+
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
|
154
|
+
:prefix => false)
|
155
|
+
bridgedifs.each_index do |index|
|
156
|
+
interface = bridgedifs[index]
|
157
|
+
@env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
|
158
|
+
end
|
159
|
+
|
160
|
+
# The range of valid choices
|
161
|
+
valid = Range.new(1, bridgedifs.length)
|
162
|
+
|
163
|
+
# The choice that the user has chosen as the bridging interface
|
164
|
+
choice = nil
|
165
|
+
while !valid.include?(choice)
|
166
|
+
choice = @env[:ui].ask("What interface should the network bridge to? Enter a number: ")
|
167
|
+
choice = choice.to_i
|
168
|
+
end
|
169
|
+
|
170
|
+
chosen_bridge = bridgedifs[choice - 1]
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
@logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge[:name]} (#{chosen_bridge[:bound_to]})")
|
175
|
+
|
176
|
+
# Given the choice we can now define the adapter we're using
|
177
|
+
return {
|
178
|
+
:adapter => config[:adapter],
|
179
|
+
:type => :bridged,
|
180
|
+
:bridge => chosen_bridge[:name],
|
181
|
+
:bound_to => chosen_bridge[:bound_to],
|
182
|
+
:mac_address => config[:mac],
|
183
|
+
:dhcp => config[:dhcp],
|
184
|
+
:ip => config[:ip],
|
185
|
+
:netmask => config[:netmask],
|
186
|
+
:nic_type => config[:nic_type]
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
101
190
|
def hostonly_config(options)
|
102
191
|
options = {
|
103
192
|
:mac => nil,
|
@@ -125,6 +125,8 @@ module VagrantPlugins
|
|
125
125
|
args.concat(["--dhcp", "yes"])
|
126
126
|
elsif adapter[:ip]
|
127
127
|
args.concat(["--ipdel", "all", "--ipadd", "#{adapter[:ip]}/#{adapter[:netmask]}"])
|
128
|
+
else
|
129
|
+
args.concat(["--dhcp", "no"])
|
128
130
|
end
|
129
131
|
|
130
132
|
if adapter[:mac_address]
|
@@ -187,23 +189,24 @@ module VagrantPlugins
|
|
187
189
|
info = {}
|
188
190
|
ifconfig = raw('ifconfig', iface['Bound To']).stdout
|
189
191
|
# Assign default values
|
190
|
-
info[:name] = iface['Network ID']
|
192
|
+
info[:name] = iface['Network ID'].gsub(/\s\(.*?\)$/, '')
|
193
|
+
info[:bound_to] = iface['Bound To']
|
191
194
|
info[:ip] = "0.0.0.0"
|
192
195
|
info[:netmask] = "0.0.0.0"
|
193
196
|
info[:status] = "Down"
|
194
197
|
|
195
|
-
ifconfig
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
info[:netmask] = $1.hex.to_s(16).scan(/../).each.map{|octet| octet.hex}.join(".")
|
203
|
-
elsif line =~ /\W(UP)\W/
|
204
|
-
info[:status] = "Up"
|
205
|
-
end
|
198
|
+
if ifconfig =~ /(?<=inet\s)(\S*)/
|
199
|
+
info[:ip] = $1.to_s
|
200
|
+
end
|
201
|
+
if ifconfig =~ /(?<=netmask\s)(\S*)/
|
202
|
+
# Netmask will be converted from hex to dec:
|
203
|
+
# '0xffffff00' -> '255.255.255.0'
|
204
|
+
info[:netmask] = $1.hex.to_s(16).scan(/../).each.map{|octet| octet.hex}.join(".")
|
206
205
|
end
|
206
|
+
if ifconfig =~ /\W(UP)\W/ and ifconfig !~ /(?<=status:\s)inactive$/
|
207
|
+
info[:status] = "Up"
|
208
|
+
end
|
209
|
+
|
207
210
|
bridged_ifaces << info
|
208
211
|
end
|
209
212
|
bridged_ifaces
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-parallels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|