Fix an error with an error. Add some comments.

This commit is contained in:
DanHam 2018-07-06 01:45:40 +01:00
parent 29503e453e
commit 36bd2f5691
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/packer/packer"
)
// This step creates switch for VM.
// This step creates an external switch for the VM.
//
// Produces:
// SwitchName string - The name of the Switch
@ -18,6 +18,9 @@ type StepCreateExternalSwitch struct {
oldSwitchName string
}
// Run runs the step required to create an external switch. Depending on
// the connectivity of the host machine, the external switch will allow the
// build VM to connect to the outside world.
func (s *StepCreateExternalSwitch) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui)
@ -30,10 +33,12 @@ func (s *StepCreateExternalSwitch) Run(_ context.Context, state multistep.StateB
packerExternalSwitchName := "paes_" + uuid.TimeOrderedUUID()
// CreateExternalVirtualSwitch checks for an existing external switch,
// creating one if required, and connects the VM to it
err = driver.CreateExternalVirtualSwitch(vmName, packerExternalSwitchName)
if err != nil {
err := fmt.Errorf("Error creating switch: %s", err)
state.Put(errorMsg, err)
err := fmt.Errorf(errorMsg, err)
state.Put("error", err)
ui.Error(err.Error())
s.SwitchName = ""
return multistep.ActionHalt