Commit c072a56b authored by Steven Merrill's avatar Steven Merrill

Finish initial compaction feature.

parent 3b49f7bd
...@@ -44,13 +44,13 @@ type Fusion5Driver struct { ...@@ -44,13 +44,13 @@ type Fusion5Driver struct {
} }
func (d *Fusion5Driver) CompactDisk(diskPath string) error { func (d *Fusion5Driver) CompactDisk(diskPath string) error {
cmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath) defragCmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath)
if _, _, err := d.runAndLog(cmd); err != nil { if _, _, err := d.runAndLog(defragCmd); err != nil {
return err return err
} }
cmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath) shrinkCmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath)
if _, _, err := d.runAndLog(cmd); err != nil { if _, _, err := d.runAndLog(shrinkCmd); err != nil {
return err return err
} }
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"path/filepath"
) )
// This step compacts the virtual disks for the VM. // This step compacts the virtual disks for the VM.
...@@ -24,7 +23,7 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { ...@@ -24,7 +23,7 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
ui.Say("Compacting the disk image") ui.Say("Compacting the disk image")
if err := driver.CompactDisk(config.FullDiskPath, fmt.Sprintf("%dM", config.DiskSize)); err != nil { if err := driver.CompactDisk(config.FullDiskPath); err != nil {
err := fmt.Errorf("Error compacting disk: %s", err) err := fmt.Errorf("Error compacting disk: %s", err)
state["error"] = err state["error"] = err
ui.Error(err.Error()) ui.Error(err.Error())
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"path/filepath"
) )
// This step creates the virtual disks for the VM. // This step creates the virtual disks for the VM.
......
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