Finish initial compaction feature.
This commit is contained in:
parent
3b49f7bd20
commit
c072a56b40
|
@ -44,13 +44,13 @@ type Fusion5Driver struct {
|
|||
}
|
||||
|
||||
func (d *Fusion5Driver) CompactDisk(diskPath string) error {
|
||||
cmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath)
|
||||
if _, _, err := d.runAndLog(cmd); err != nil {
|
||||
defragCmd := exec.Command(d.vdiskManagerPath(), "-d", diskPath)
|
||||
if _, _, err := d.runAndLog(defragCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath)
|
||||
if _, _, err := d.runAndLog(cmd); err != nil {
|
||||
shrinkCmd := exec.Command(d.vdiskManagerPath(), "-k", diskPath)
|
||||
if _, _, err := d.runAndLog(shrinkCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// This step compacts the virtual disks for the VM.
|
||||
|
@ -24,7 +23,7 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
|
|||
ui := state["ui"].(packer.Ui)
|
||||
|
||||
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)
|
||||
state["error"] = err
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// This step creates the virtual disks for the VM.
|
||||
|
|
Loading…
Reference in New Issue