forcefully stop parallels vm.

also only output parallels version once.
This commit is contained in:
Matthew Hooker 2018-04-19 16:11:29 -07:00
parent 508064d0af
commit c920e0a20b
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
3 changed files with 3 additions and 3 deletions

View File

@ -131,6 +131,7 @@ func NewDriver() (Driver, error) {
latestDriver := 11
version, _ := drivers[strconv.Itoa(latestDriver)].Version()
majVer, _ := strconv.Atoi(strings.SplitN(version, ".", 2)[0])
log.Printf("Parallels version: %s", version)
if majVer > latestDriver {
log.Printf("Your version of Parallels Desktop for Mac is %s, Packer will use driver for version %d.", version, latestDriver)
return drivers[strconv.Itoa(latestDriver)], nil

View File

@ -222,7 +222,7 @@ func (d *Parallels9Driver) IsRunning(name string) (bool, error) {
// Stop forcibly stops the VM.
func (d *Parallels9Driver) Stop(name string) error {
if err := d.Prlctl("stop", name); err != nil {
if err := d.Prlctl("stop", name, "--kill"); err != nil {
return err
}
@ -275,7 +275,6 @@ func (d *Parallels9Driver) Version() (string, error) {
}
version := matches[1]
log.Printf("Parallels Desktop version: %s", version)
return version, nil
}

View File

@ -69,7 +69,7 @@ func (s *StepRun) Cleanup(state multistep.StateBag) {
ui := state.Get("ui").(packer.Ui)
if running, _ := driver.IsRunning(s.vmName); running {
if err := driver.Prlctl("stop", s.vmName); err != nil {
if err := driver.Stop(s.vmName); err != nil {
ui.Error(fmt.Sprintf("Error stopping VM: %s", err))
}
}