2013-07-01 22:25:33 -04:00
|
|
|
package vmware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
)
|
|
|
|
|
2013-07-02 01:15:03 -04:00
|
|
|
// This step compacts the virtual disk for the VM.
|
2013-07-01 22:25:33 -04:00
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// driver Driver
|
|
|
|
// ui packer.Ui
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
// <nothing>
|
|
|
|
type stepCompactDisk struct{}
|
|
|
|
|
|
|
|
func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
|
|
|
|
driver := state["driver"].(Driver)
|
|
|
|
ui := state["ui"].(packer.Ui)
|
2013-07-02 01:12:57 -04:00
|
|
|
full_disk_path := state["full_disk_path"].(string)
|
2013-07-01 22:25:33 -04:00
|
|
|
|
|
|
|
ui.Say("Compacting the disk image")
|
2013-07-02 01:12:57 -04:00
|
|
|
if err := driver.CompactDisk(full_disk_path); err != nil {
|
2013-07-02 12:10:44 -04:00
|
|
|
state["error"] := fmt.Errorf("Error compacting disk: %s", err)
|
2013-07-01 22:25:33 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stepCompactDisk) Cleanup(map[string]interface{}) {}
|