package common import ( "context" "fmt" "github.com/hashicorp/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" ) type StepDisableVlan struct { } func (s *StepDisableVlan) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.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 }