-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
step_prepare_tools.go
41 lines (32 loc) · 1021 Bytes
/
step_prepare_tools.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package common
import (
"context"
"fmt"
"os"
"github.com/hashicorp/packer/helper/multistep"
)
type StepPrepareTools struct {
RemoteType string
ToolsUploadFlavor string
}
func (c *StepPrepareTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
if c.RemoteType == "esx5" {
return multistep.ActionContinue
}
if c.ToolsUploadFlavor == "" {
return multistep.ActionContinue
}
path := driver.ToolsIsoPath(c.ToolsUploadFlavor)
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) {}