From 48b6cc065053ce5261fe41ad8881f4e66e019180 Mon Sep 17 00:00:00 2001 From: James Johnson Date: Wed, 21 Sep 2016 18:31:06 +0000 Subject: [PATCH] Enable VlanID --- builder/hyperv/common/step_configure_vlan.go | 7 ++++--- builder/hyperv/iso/builder.go | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/builder/hyperv/common/step_configure_vlan.go b/builder/hyperv/common/step_configure_vlan.go index 94f445ddd..cd0b34169 100644 --- a/builder/hyperv/common/step_configure_vlan.go +++ b/builder/hyperv/common/step_configure_vlan.go @@ -11,7 +11,7 @@ import ( ) type StepConfigureVlan struct { - vlanId string + VlanID string } func (s *StepConfigureVlan) Run(state multistep.StateBag) multistep.StepAction { @@ -24,10 +24,11 @@ func (s *StepConfigureVlan) Run(state multistep.StateBag) multistep.StepAction { ui.Say("Configuring vlan...") - vlanId := s.vlanId + vlanId := s.VlanID if vlanId == "" { - vlanId = "1724" + // If no vlan ID is specified, do not enable Virtual LAN Identification + return multistep.ActionContinue } err := driver.SetNetworkAdapterVlanId(switchName, vlanId) diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 0772e24ba..162e3c915 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -87,6 +87,7 @@ type Config struct { BootCommand []string `mapstructure:"boot_command"` SwitchName string `mapstructure:"switch_name"` + VlandID string `mapstructure:"vlan_id"` Cpu uint `mapstructure:"cpu"` Generation uint `mapstructure:"generation"` EnableMacSpoofing bool `mapstructure:"enable_mac_spoofing"` @@ -353,6 +354,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe IsoPaths: b.config.SecondaryDvdImages, Generation: b.config.Generation, }, + + &hypervcommon.StepConfigureVlan{ + VlanID: b.config.VlandID, + }, &hypervcommon.StepRun{ BootWait: b.config.BootWait,