github.phpd.cn/hashicorp/packer@v1.3.2/builder/vmware/common/step_prepare_tools.go (about) 1 package common 2 3 import ( 4 "context" 5 "fmt" 6 "os" 7 8 "github.com/hashicorp/packer/helper/multistep" 9 ) 10 11 type StepPrepareTools struct { 12 RemoteType string 13 ToolsUploadFlavor string 14 } 15 16 func (c *StepPrepareTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { 17 driver := state.Get("driver").(Driver) 18 19 if c.RemoteType == "esx5" { 20 return multistep.ActionContinue 21 } 22 23 if c.ToolsUploadFlavor == "" { 24 return multistep.ActionContinue 25 } 26 27 path := driver.ToolsIsoPath(c.ToolsUploadFlavor) 28 if _, err := os.Stat(path); err != nil { 29 state.Put("error", fmt.Errorf( 30 "Couldn't find VMware tools for '%s'! VMware often downloads these\n"+ 31 "tools on-demand. However, to do this, you need to create a fake VM\n"+ 32 "of the proper type then click the 'install tools' option in the\n"+ 33 "VMware GUI.", c.ToolsUploadFlavor)) 34 return multistep.ActionHalt 35 } 36 37 state.Put("tools_upload_source", path) 38 return multistep.ActionContinue 39 } 40 41 func (c *StepPrepareTools) Cleanup(multistep.StateBag) {}