2014-11-27 09:13:50 -05:00
|
|
|
package iso
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2014-11-27 09:13:50 -05:00
|
|
|
"fmt"
|
2016-12-11 14:13:37 -05:00
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
parallelscommon "github.com/hashicorp/packer/builder/parallels/common"
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2014-11-27 09:13:50 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// This step sets the device boot order for the virtual machine.
|
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// driver Driver
|
|
|
|
// ui packer.Ui
|
|
|
|
// vmName string
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
type stepSetBootOrder struct{}
|
|
|
|
|
2018-01-22 18:31:41 -05:00
|
|
|
func (s *stepSetBootOrder) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
2014-11-27 09:13:50 -05:00
|
|
|
driver := state.Get("driver").(parallelscommon.Driver)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
vmName := state.Get("vmName").(string)
|
|
|
|
|
|
|
|
// Set new boot order
|
|
|
|
ui.Say("Setting the boot order...")
|
|
|
|
command := []string{
|
|
|
|
"set", vmName,
|
|
|
|
"--device-bootorder", fmt.Sprintf("hdd0 cdrom0 net0"),
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := driver.Prlctl(command...); err != nil {
|
|
|
|
err := fmt.Errorf("Error setting the boot order: %s", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *stepSetBootOrder) Cleanup(state multistep.StateBag) {}
|