2014-09-02 04:42:12 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2016-12-11 14:13:37 -05:00
|
|
|
|
|
|
|
"github.com/mitchellh/multistep"
|
2014-09-02 04:42:12 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// This step prepares parameters related to Parallels Tools.
|
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// driver Driver
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
// parallels_tools_path string
|
|
|
|
type StepPrepareParallelsTools struct {
|
|
|
|
ParallelsToolsFlavor string
|
|
|
|
ParallelsToolsMode string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepPrepareParallelsTools) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
|
|
|
|
if s.ParallelsToolsMode == ParallelsToolsModeDisable {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2016-12-11 13:49:54 -05:00
|
|
|
path, err := driver.ToolsISOPath(s.ParallelsToolsFlavor)
|
2014-09-02 04:42:12 -04:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
state.Put("error", err)
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
state.Put("error", fmt.Errorf(
|
|
|
|
"Couldn't find Parallels Tools for the '%s' flavor! Please, check the\n"+
|
|
|
|
"value of 'parallels_tools_flavor'. Valid flavors are: 'win', 'lin',\n"+
|
|
|
|
"'mac', 'os2' and 'other'", s.ParallelsToolsFlavor))
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
state.Put("parallels_tools_path", path)
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepPrepareParallelsTools) Cleanup(multistep.StateBag) {}
|