github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/builder/hyperv/common/step_disable_vlan.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 ) 8 9 type StepDisableVlan struct { 10 } 11 12 func (s *StepDisableVlan) Run(state multistep.StateBag) multistep.StepAction { 13 driver := state.Get("driver").(Driver) 14 ui := state.Get("ui").(packer.Ui) 15 16 errorMsg := "Error disabling vlan: %s" 17 vmName := state.Get("vmName").(string) 18 switchName := state.Get("SwitchName").(string) 19 20 ui.Say("Disabling vlan...") 21 22 err := driver.UntagVirtualMachineNetworkAdapterVlan(vmName, switchName) 23 if err != nil { 24 err := fmt.Errorf(errorMsg, err) 25 state.Put("error", err) 26 ui.Error(err.Error()) 27 return multistep.ActionHalt 28 } 29 30 return multistep.ActionContinue 31 } 32 33 func (s *StepDisableVlan) Cleanup(state multistep.StateBag) { 34 //do nothing 35 }