Improved behavior for case if vlan_id is not set

This commit is contained in:
Volodymyr Babchynskyy 2015-03-30 10:17:29 -06:00
parent 9e23d16d9c
commit 9a0aab4bd7
2 changed files with 12 additions and 18 deletions

View File

@ -8,9 +8,10 @@ module VagrantPlugins
def call(env)
vlan_id = env[:machine].provider_config.vlan_id
env[:ui].info("[Settings] [Network Adapter] Setting Vlan ID to: #{vlan_id}")
env[:machine].provider.driver.net_set_vlan(vlan_id)
if vlan_id
env[:ui].info("[Settings] [Network Adapter] Setting Vlan ID to: #{vlan_id}")
env[:machine].provider.driver.net_set_vlan(vlan_id)
end
@app.call(env)
end
end

View File

@ -3,20 +3,13 @@ require "vagrant"
module VagrantPlugins
module HyperV
class Config < Vagrant.plugin("2", :config)
# The timeout to wait for an IP address when booting the machine,
# in seconds.
#
# @return [Integer]
attr_accessor :ip_address_timeout
attr_accessor :memory
attr_accessor :maxmemory
attr_accessor :cpus
attr_accessor :vmname
# The default VLAN ID for network interface for the virtual machine.
#
# @return [Integer]
attr_accessor :vlan_id
attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer]
attr_accessor :memory # Memory size in mb @return [Integer]
attr_accessor :maxmemory # Maximal memory size in mb enables dynamical memory allocation @return [Integer]
attr_accessor :cpus # Number of cpu's @return [Integer]
attr_accessor :vmname # Name that will be shoen in Hyperv Manager @return [String]
attr_accessor :vlan_id # VLAN ID for network interface for the virtual machine. @return [Integer]
def initialize
@ip_address_timeout = UNSET_VALUE
@ -35,7 +28,7 @@ module VagrantPlugins
@maxmemory = nil if @maxmemory == UNSET_VALUE
@cpus = nil if @cpus == UNSET_VALUE
@vmname = nil if @vmname == UNSET_VALUE
@vlan_id = 0 if @vlan_id == UNSET_VALUE
@vlan_id = nil if @vlan_id == UNSET_VALUE
end
def validate(machine)