From 9a0aab4bd783240d1938026ec4a4d4f355fe49cc Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 10:17:29 -0600 Subject: [PATCH] Improved behavior for case if vlan_id is not set --- .../providers/hyperv/action/net_set_vlan.rb | 7 +++--- plugins/providers/hyperv/config.rb | 23 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/plugins/providers/hyperv/action/net_set_vlan.rb b/plugins/providers/hyperv/action/net_set_vlan.rb index 9ce26d324..c65f5a7cb 100644 --- a/plugins/providers/hyperv/action/net_set_vlan.rb +++ b/plugins/providers/hyperv/action/net_set_vlan.rb @@ -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 diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index 55c1be673..fe247a242 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -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)