builder/parallels-iso: Configuration of disk type, plain or expanding
This commit is contained in:
parent
33aa372835
commit
52d4514d6a
|
@ -37,6 +37,7 @@ type Config struct {
|
|||
|
||||
BootCommand []string `mapstructure:"boot_command"`
|
||||
DiskSize uint `mapstructure:"disk_size"`
|
||||
DiskType string `mapstructure:"disk_type"`
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
HardDriveInterface string `mapstructure:"hard_drive_interface"`
|
||||
HostInterfaces []string `mapstructure:"host_interfaces"`
|
||||
|
@ -87,6 +88,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
b.config.DiskSize = 40000
|
||||
}
|
||||
|
||||
if b.config.DiskType == "" {
|
||||
b.config.DiskType = "expand"
|
||||
}
|
||||
|
||||
if b.config.HardDriveInterface == "" {
|
||||
b.config.HardDriveInterface = "sata"
|
||||
}
|
||||
|
@ -104,6 +109,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
b.config.VMName = fmt.Sprintf("packer-%s", b.config.PackerBuildName)
|
||||
}
|
||||
|
||||
if b.config.DiskType != "expand" && b.config.DiskType != "plain" {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, errors.New("disk_type can only be expand, or plain"))
|
||||
}
|
||||
|
||||
if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, errors.New("hard_drive_interface can only be ide, sata, or scsi"))
|
||||
|
|
|
@ -130,6 +130,47 @@ func TestBuilderPrepare_DiskSize(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_DiskType(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test a default boot_wait
|
||||
delete(config, "disk_type")
|
||||
warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.DiskType != "expand" {
|
||||
t.Fatalf("bad: %s", b.config.DiskType)
|
||||
}
|
||||
|
||||
// Test with a bad
|
||||
config["disk_type"] = "fake"
|
||||
b = Builder{}
|
||||
warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test with a good
|
||||
config["disk_type"] = "plain"
|
||||
b = Builder{}
|
||||
warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
|
|
@ -22,6 +22,7 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
|
|||
command := []string{
|
||||
"set", vmName,
|
||||
"--device-add", "hdd",
|
||||
"--type", config.DiskType,
|
||||
"--size", strconv.FormatUint(uint64(config.DiskSize), 10),
|
||||
"--iface", config.HardDriveInterface,
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ type PluginCommand struct {
|
|||
var Builders = map[string]packer.Builder{
|
||||
"amazon-chroot": new(amazonchrootbuilder.Builder),
|
||||
"amazon-ebs": new(amazonebsbuilder.Builder),
|
||||
"amazon-ebsvolume": new(amazonebsvolumebuilder.Builder),
|
||||
"amazon-ebssurrogate": new(amazonebssurrogatebuilder.Builder),
|
||||
"amazon-ebsvolume": new(amazonebsvolumebuilder.Builder),
|
||||
"amazon-instance": new(amazoninstancebuilder.Builder),
|
||||
"azure-arm": new(azurearmbuilder.Builder),
|
||||
"cloudstack": new(cloudstackbuilder.Builder),
|
||||
|
|
|
@ -105,6 +105,13 @@ builder.
|
|||
- `disk_size` (integer) - The size, in megabytes, of the hard disk to create
|
||||
for the VM. By default, this is 40000 (about 40 GB).
|
||||
|
||||
- `disk_type` (string) - The type for image file based virtual disk drives,
|
||||
defaults to `expand`. Valid options are `expand` (expanding disk) that the
|
||||
image file is small initially and grows in size as you add data to it, and
|
||||
`plain` (plain disk) that the image file has a fixed size from the moment it
|
||||
is created (i.e the space is allocated for the drive fully). Plain disks
|
||||
perform faster than expanding disks.
|
||||
|
||||
- `floppy_files` (array of strings) - A list of files to place onto a floppy
|
||||
disk that is attached when the VM is booted. This is most useful for
|
||||
unattended Windows installs, which look for an `Autounattend.xml` file on
|
||||
|
@ -273,7 +280,7 @@ proper key:
|
|||
|
||||
- `<leftAltOn>` `<rightAltOn>` - Simulates pressing and holding the alt key.
|
||||
|
||||
- `<leftCtrlOn>` `<rightCtrlOn>` - Simulates pressing and holding the ctrl key.
|
||||
- `<leftCtrlOn>` `<rightCtrlOn>` - Simulates pressing and holding the ctrl key.
|
||||
|
||||
- `<leftShiftOn>` `<rightShiftOn>` - Simulates pressing and holding the shift key.
|
||||
|
||||
|
@ -287,9 +294,9 @@ proper key:
|
|||
sending any additional keys. This is useful if you have to generally wait
|
||||
for the UI to update before typing more.
|
||||
|
||||
When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them,
|
||||
otherwise they will be held down until the machine reboots. Use lowercase
|
||||
characters as well inside modifiers.
|
||||
When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them,
|
||||
otherwise they will be held down until the machine reboots. Use lowercase
|
||||
characters as well inside modifiers.
|
||||
|
||||
For example: to simulate ctrl+c use `<leftCtrlOn>c<leftCtrlOff>`.
|
||||
|
||||
|
|
Loading…
Reference in New Issue