2013-07-01 13:40:38 -04:00
|
|
|
package vmware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type stepPrepareTools struct{}
|
|
|
|
|
2013-08-31 15:50:25 -04:00
|
|
|
func (*stepPrepareTools) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
config := state.Get("config").(*config)
|
|
|
|
driver := state.Get("driver").(Driver)
|
2013-07-01 13:40:38 -04:00
|
|
|
|
|
|
|
if config.ToolsUploadFlavor == "" {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
path := driver.ToolsIsoPath(config.ToolsUploadFlavor)
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
2013-08-31 15:50:25 -04:00
|
|
|
state.Put("error", fmt.Errorf(
|
2013-07-01 13:40:38 -04:00
|
|
|
"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 15:50:25 -04:00
|
|
|
"VMware GUI.", config.ToolsUploadFlavor))
|
2013-07-01 13:40:38 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:50:25 -04:00
|
|
|
state.Put("tools_upload_source", path)
|
2013-07-01 13:40:38 -04:00
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:50:25 -04:00
|
|
|
func (*stepPrepareTools) Cleanup(multistep.StateBag) {}
|