packer-cn/builder/vmware/vmx/step_clone_vmx.go

40 lines
922 B
Go
Raw Normal View History

2013-12-26 10:34:27 -05:00
package vmx
import (
"log"
"path/filepath"
"github.com/mitchellh/multistep"
2013-12-26 16:39:41 -05:00
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
2013-12-26 10:34:27 -05:00
"github.com/mitchellh/packer/packer"
)
// StepCloneVMX takes a VMX file and clones the VM into the output directory.
type StepCloneVMX struct {
OutputDir string
Path string
VMName string
}
func (s *StepCloneVMX) Run(state multistep.StateBag) multistep.StepAction {
2013-12-26 16:39:41 -05:00
driver := state.Get("driver").(vmwcommon.Driver)
2013-12-26 10:34:27 -05:00
ui := state.Get("ui").(packer.Ui)
vmxPath := filepath.Join(s.OutputDir, s.VMName+".vmx")
2013-12-26 16:39:41 -05:00
ui.Say("Cloning source VM...")
2013-12-26 10:34:27 -05:00
log.Printf("Cloning from: %s", s.Path)
log.Printf("Cloning to: %s", vmxPath)
2013-12-26 16:39:41 -05:00
if err := driver.Clone(vmxPath, s.Path); err != nil {
2013-12-26 10:34:27 -05:00
state.Put("error", err)
return multistep.ActionHalt
}
state.Put("vmx_path", vmxPath)
return multistep.ActionContinue
}
func (s *StepCloneVMX) Cleanup(state multistep.StateBag) {
}