Ability to specify `:bridge` to networking [GH-655]
This commit is contained in:
parent
26d9636faf
commit
a6a42b31df
|
@ -12,6 +12,8 @@
|
||||||
that are up as choices. [GH-701]
|
that are up as choices. [GH-701]
|
||||||
- More intelligent handling of the `certname` option for puppet
|
- More intelligent handling of the `certname` option for puppet
|
||||||
server. [GH-702]
|
server. [GH-702]
|
||||||
|
- You may now explicitly set the network to bridge to in the Vagrantfile
|
||||||
|
using the `:bridge` parameter. [GH-655]
|
||||||
|
|
||||||
## 0.9.4 (January 28, 2012)
|
## 0.9.4 (January 28, 2012)
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ module Vagrant
|
||||||
return {
|
return {
|
||||||
:adapter => nil,
|
:adapter => nil,
|
||||||
:mac => nil,
|
:mac => nil,
|
||||||
|
:bridge => nil,
|
||||||
:auto_config => true
|
:auto_config => true
|
||||||
}.merge(options)
|
}.merge(options)
|
||||||
end
|
end
|
||||||
|
@ -322,32 +323,60 @@ module Vagrant
|
||||||
bridgedifs = @env[:vm].driver.read_bridged_interfaces
|
bridgedifs = @env[:vm].driver.read_bridged_interfaces
|
||||||
bridgedifs.delete_if { |interface| interface[:status] == "Down" }
|
bridgedifs.delete_if { |interface| interface[:status] == "Down" }
|
||||||
|
|
||||||
|
# The name of the chosen bridge interface will be assigned to this
|
||||||
|
# variable.
|
||||||
chosen_bridge = nil
|
chosen_bridge = nil
|
||||||
if bridgedifs.length == 1
|
|
||||||
# One bridgable interface? Just use it.
|
if config[:bridge]
|
||||||
chosen_bridge = bridgedifs[0][:name]
|
@logger.debug("Bridge was directly specified in config, searching for: #{config[:bridge]}")
|
||||||
@logger.debug("Only one bridged interface available. Using it by default.")
|
|
||||||
else
|
# Search for a matching bridged interface
|
||||||
# More than one bridgable interface requires a user decision, so
|
bridgedifs.each do |interface|
|
||||||
# show options to choose from.
|
if interface[:name].downcase == config[:bridge].downcase
|
||||||
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
|
@logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.")
|
||||||
:prefix => false)
|
chosen_bridge = interface[:name]
|
||||||
bridgedifs.each_index do |index|
|
break
|
||||||
interface = bridgedifs[index]
|
end
|
||||||
@env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# The range of valid choices
|
# If one wasn't found, then we notify the user here.
|
||||||
valid = Range.new(1, bridgedifs.length)
|
if !chosen_bridge
|
||||||
|
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.specific_not_found",
|
||||||
# The choice that the user has chosen as the bridging interface
|
:bridge => config[:bridge])
|
||||||
choice = nil
|
|
||||||
while !valid.include?(choice)
|
|
||||||
choice = @env[:ui].ask("What interface should the network bridge to? ")
|
|
||||||
choice = choice.to_i
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
chosen_bridge = bridgedifs[choice - 1][:name]
|
# If we still don't have a bridge chosen (this means that one wasn't
|
||||||
|
# specified in the Vagrantfile, or the bridge specified in the Vagrantfile
|
||||||
|
# wasn't found), then we fall back to the normal means of searchign for a
|
||||||
|
# bridged network.
|
||||||
|
if !chosen_bridge
|
||||||
|
if bridgedifs.length == 1
|
||||||
|
# One bridgable interface? Just use it.
|
||||||
|
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
|
||||||
|
# show options to choose from.
|
||||||
|
@env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
|
||||||
|
:prefix => false)
|
||||||
|
bridgedifs.each_index do |index|
|
||||||
|
interface = bridgedifs[index]
|
||||||
|
@env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
# The range of valid choices
|
||||||
|
valid = Range.new(1, bridgedifs.length)
|
||||||
|
|
||||||
|
# The choice that the user has chosen as the bridging interface
|
||||||
|
choice = nil
|
||||||
|
while !valid.include?(choice)
|
||||||
|
choice = @env[:ui].ask("What interface should the network bridge to? ")
|
||||||
|
choice = choice.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
chosen_bridge = bridgedifs[choice - 1][:name]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge}")
|
@logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge}")
|
||||||
|
|
|
@ -299,6 +299,9 @@ en:
|
||||||
Enabling bridged network...
|
Enabling bridged network...
|
||||||
preparing: |-
|
preparing: |-
|
||||||
Preparing bridged networking...
|
Preparing bridged networking...
|
||||||
|
specific_not_found: |-
|
||||||
|
Specific bridge '%{bridge}' not found. You may be asked to specify
|
||||||
|
which network to bridge to.
|
||||||
check_box:
|
check_box:
|
||||||
not_found: Box %{name} was not found. Fetching box from specified URL...
|
not_found: Box %{name} was not found. Fetching box from specified URL...
|
||||||
not_specified: |-
|
not_specified: |-
|
||||||
|
|
Loading…
Reference in New Issue