2014-04-06 13:21:22 -04:00
|
|
|
package iso
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2014-04-06 13:21:22 -04:00
|
|
|
"fmt"
|
2016-12-11 14:13:37 -05:00
|
|
|
"strconv"
|
|
|
|
|
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-04-06 13:21:22 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// This step creates the virtual disk that will be used as the
|
|
|
|
// hard drive for the virtual machine.
|
|
|
|
type stepCreateDisk struct{}
|
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2015-05-27 16:49:31 -04:00
|
|
|
config := state.Get("config").(*Config)
|
2014-04-06 13:21:22 -04:00
|
|
|
driver := state.Get("driver").(parallelscommon.Driver)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
vmName := state.Get("vmName").(string)
|
|
|
|
|
|
|
|
command := []string{
|
|
|
|
"set", vmName,
|
2014-10-01 08:04:22 -04:00
|
|
|
"--device-add", "hdd",
|
2017-03-03 18:32:51 -05:00
|
|
|
"--type", config.DiskType,
|
2014-04-06 13:21:22 -04:00
|
|
|
"--size", strconv.FormatUint(uint64(config.DiskSize), 10),
|
|
|
|
"--iface", config.HardDriveInterface,
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.Say("Creating hard drive...")
|
|
|
|
err := driver.Prlctl(command...)
|
|
|
|
if err != nil {
|
|
|
|
err := fmt.Errorf("Error creating hard drive: %s", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *stepCreateDisk) Cleanup(state multistep.StateBag) {}
|