github.com/rothwerx/packer@v0.9.0/builder/vmware/common/step_prepare_tools.go (about)

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