2014-05-09 20:24:19 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2014-05-09 20:24:19 -04:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2014-05-10 13:16:53 -04:00
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2014-05-09 20:24:19 -04:00
|
|
|
)
|
|
|
|
|
2014-05-10 00:12:14 -04:00
|
|
|
type StepPrepareTools struct {
|
2014-05-10 13:16:53 -04:00
|
|
|
RemoteType string
|
|
|
|
ToolsUploadFlavor string
|
2020-09-23 18:07:42 -04:00
|
|
|
ToolsSourcePath string
|
2014-05-09 20:24:19 -04:00
|
|
|
}
|
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (c *StepPrepareTools) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2014-05-09 20:24:19 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
|
|
|
|
if c.RemoteType == "esx5" {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2020-09-23 18:07:42 -04:00
|
|
|
if c.ToolsUploadFlavor == "" && c.ToolsSourcePath == "" {
|
2014-05-09 20:24:19 -04:00
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2020-09-23 18:07:42 -04:00
|
|
|
path := c.ToolsSourcePath
|
|
|
|
if path == "" {
|
|
|
|
path = driver.ToolsIsoPath(c.ToolsUploadFlavor)
|
|
|
|
}
|
|
|
|
|
2014-05-09 20:24:19 -04:00
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
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"+
|
|
|
|
"VMware GUI.", c.ToolsUploadFlavor))
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
state.Put("tools_upload_source", path)
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *StepPrepareTools) Cleanup(multistep.StateBag) {}
|