packer-cn/builder/vmware/iso/step_prepare_tools.go

39 lines
1.0 KiB
Go
Raw Normal View History

2013-12-23 22:58:41 -07:00
package iso
import (
"fmt"
"github.com/mitchellh/multistep"
2013-12-24 11:31:57 -07:00
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
"os"
)
type stepPrepareTools struct{}
2013-08-31 12:50:25 -07:00
func (*stepPrepareTools) Run(state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(*config)
2013-12-24 11:31:57 -07:00
driver := state.Get("driver").(vmwcommon.Driver)
if config.RemoteType == "esx5" {
return multistep.ActionContinue
}
if config.ToolsUploadFlavor == "" {
return multistep.ActionContinue
}
path := driver.ToolsIsoPath(config.ToolsUploadFlavor)
if _, err := os.Stat(path); err != nil {
2013-08-31 12:50:25 -07:00
state.Put("error", fmt.Errorf(
"Couldn't find VMware tools for '%s'! VMware often downloads these\n"+
"tools on-demand. However, to do this, you need to create a fake VM\n"+
"of the proper type then click the 'install tools' option in the\n"+
2013-08-31 12:50:25 -07:00
"VMware GUI.", config.ToolsUploadFlavor))
return multistep.ActionHalt
}
2013-08-31 12:50:25 -07:00
state.Put("tools_upload_source", path)
return multistep.ActionContinue
}
2013-08-31 12:50:25 -07:00
func (*stepPrepareTools) Cleanup(multistep.StateBag) {}