mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-21 07:21:40 -04:00
https://github.com/Microsoft/packer-hyperv/pull/21/commits/1ce6ba91f7308e1283d5d1dcc35ed43b95303ff7?diff=unified#diff-5d60887f0940c9f8d6724e59843ac1fb
36 lines
777 B
Go
36 lines
777 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/mitchellh/multistep"
|
|
"github.com/mitchellh/packer/packer"
|
|
)
|
|
|
|
type StepDisableVlan struct {
|
|
}
|
|
|
|
func (s *StepDisableVlan) Run(state multistep.StateBag) multistep.StepAction {
|
|
driver := state.Get("driver").(Driver)
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
errorMsg := "Error disabling vlan: %s"
|
|
vmName := state.Get("vmName").(string)
|
|
switchName := state.Get("SwitchName").(string)
|
|
|
|
ui.Say("Disabling vlan...")
|
|
|
|
err := driver.UntagVirtualMachineNetworkAdapterVlan(vmName, switchName)
|
|
if err != nil {
|
|
err := fmt.Errorf(errorMsg, err)
|
|
state.Put("error", err)
|
|
ui.Error(err.Error())
|
|
return multistep.ActionHalt
|
|
}
|
|
|
|
return multistep.ActionContinue
|
|
}
|
|
|
|
func (s *StepDisableVlan) Cleanup(state multistep.StateBag) {
|
|
//do nothing
|
|
}
|