Commit 1479e983 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #328 from jbronn/vmdk_type

builder/vmware: Enable customization of VMDK type with `disk_type_id`
parents 9e12492f 4d21ce01
...@@ -27,6 +27,7 @@ type config struct { ...@@ -27,6 +27,7 @@ type config struct {
DiskName string `mapstructure:"vmdk_name"` DiskName string `mapstructure:"vmdk_name"`
DiskSize uint `mapstructure:"disk_size"` DiskSize uint `mapstructure:"disk_size"`
DiskTypeId string `mapstructure:"disk_type_id"`
FloppyFiles []string `mapstructure:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files"`
GuestOSType string `mapstructure:"guest_os_type"` GuestOSType string `mapstructure:"guest_os_type"`
ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksum string `mapstructure:"iso_checksum"`
...@@ -84,6 +85,11 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -84,6 +85,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.DiskSize = 40000 b.config.DiskSize = 40000
} }
if b.config.DiskTypeId == "" {
// Default is growable virtual disk split in 2GB files.
b.config.DiskTypeId = "1"
}
if b.config.FloppyFiles == nil { if b.config.FloppyFiles == nil {
b.config.FloppyFiles = make([]string, 0) b.config.FloppyFiles = make([]string, 0)
} }
......
...@@ -15,7 +15,7 @@ type Driver interface { ...@@ -15,7 +15,7 @@ type Driver interface {
CompactDisk(string) error CompactDisk(string) error
// CreateDisk creates a virtual disk with the given size. // CreateDisk creates a virtual disk with the given size.
CreateDisk(string, string) error CreateDisk(string, string, string) error
// Checks if the VMX file at the given path is running. // Checks if the VMX file at the given path is running.
IsRunning(string) (bool, error) IsRunning(string) (bool, error)
......
...@@ -28,8 +28,8 @@ func (d *Fusion5Driver) CompactDisk(diskPath string) error { ...@@ -28,8 +28,8 @@ func (d *Fusion5Driver) CompactDisk(diskPath string) error {
return nil return nil
} }
func (d *Fusion5Driver) CreateDisk(output string, size string) error { func (d *Fusion5Driver) CreateDisk(output string, size string, type_id string) error {
cmd := exec.Command(d.vdiskManagerPath(), "-c", "-s", size, "-a", "lsilogic", "-t", "1", output) cmd := exec.Command(d.vdiskManagerPath(), "-c", "-s", size, "-a", "lsilogic", "-t", type_id, output)
if _, _, err := runAndLog(cmd); err != nil { if _, _, err := runAndLog(cmd); err != nil {
return err return err
} }
......
...@@ -51,12 +51,12 @@ func (d *Player5LinuxDriver) qemuCompactDisk(diskPath string) error { ...@@ -51,12 +51,12 @@ func (d *Player5LinuxDriver) qemuCompactDisk(diskPath string) error {
return nil return nil
} }
func (d *Player5LinuxDriver) CreateDisk(output string, size string) error { func (d *Player5LinuxDriver) CreateDisk(output string, size string, type_id string) error {
var cmd *exec.Cmd var cmd *exec.Cmd
if d.QemuImgPath != "" { if d.QemuImgPath != "" {
cmd = exec.Command(d.QemuImgPath, "create", "-f", "vmdk", "-o", "compat6", output, size) cmd = exec.Command(d.QemuImgPath, "create", "-f", "vmdk", "-o", "compat6", output, size)
} else { } else {
cmd = exec.Command(d.VdiskManagerPath, "-c", "-s", size, "-a", "lsilogic", "-t", "1", output) cmd = exec.Command(d.VdiskManagerPath, "-c", "-s", size, "-a", "lsilogic", "-t", type_id, output)
} }
if _, _, err := runAndLog(cmd); err != nil { if _, _, err := runAndLog(cmd); err != nil {
return err return err
......
...@@ -31,8 +31,8 @@ func (d *Workstation9Driver) CompactDisk(diskPath string) error { ...@@ -31,8 +31,8 @@ func (d *Workstation9Driver) CompactDisk(diskPath string) error {
return nil return nil
} }
func (d *Workstation9Driver) CreateDisk(output string, size string) error { func (d *Workstation9Driver) CreateDisk(output string, size string, type_id string) error {
cmd := exec.Command(d.VdiskManagerPath, "-c", "-s", size, "-a", "lsilogic", "-t", "1", output) cmd := exec.Command(d.VdiskManagerPath, "-c", "-s", size, "-a", "lsilogic", "-t", type_id, output)
if _, _, err := runAndLog(cmd); err != nil { if _, _, err := runAndLog(cmd); err != nil {
return err return err
} }
......
...@@ -25,7 +25,7 @@ func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction { ...@@ -25,7 +25,7 @@ func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction {
ui.Say("Creating virtual machine disk") ui.Say("Creating virtual machine disk")
full_disk_path := filepath.Join(config.OutputDir, config.DiskName+".vmdk") full_disk_path := filepath.Join(config.OutputDir, config.DiskName+".vmdk")
if err := driver.CreateDisk(full_disk_path, fmt.Sprintf("%dM", config.DiskSize)); err != nil { if err := driver.CreateDisk(full_disk_path, fmt.Sprintf("%dM", config.DiskSize), config.DiskTypeId); err != nil {
err := fmt.Errorf("Error creating disk: %s", err) err := fmt.Errorf("Error creating disk: %s", err)
state["error"] = err state["error"] = err
ui.Error(err.Error()) ui.Error(err.Error())
......
...@@ -80,6 +80,12 @@ Optional: ...@@ -80,6 +80,12 @@ Optional:
actual file representing the disk will not use the full size unless it is full. actual file representing the disk will not use the full size unless it is full.
By default this is set to 40,000 (40 GB). By default this is set to 40,000 (40 GB).
* `disk_type_id` (string) - The type of VMware virtual disk to create.
The default is "1", which corresponds to a growable virtual disk split in
2GB files. This option is for advanced usage, modify only if you
know what you're doing. For more information, please consult the
[Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf).
* `floppy_files` (array of strings) - A list of files to put onto a floppy * `floppy_files` (array of strings) - A list of files to put onto a floppy
disk that is attached when the VM is booted for the first time. This is disk that is attached when the VM is booted for the first time. This is
most useful for unattended Windows installs, which look for an most useful for unattended Windows installs, which look for an
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment