2015-06-21 07:36:07 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2015-06-21 07:36:07 -04:00
|
|
|
"fmt"
|
2018-01-22 18:32:33 -05:00
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2015-06-21 07:36:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepEnableIntegrationService struct {
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (s *StepEnableIntegrationService) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2015-10-30 04:23:30 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
2015-06-21 07:36:07 -04:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
ui.Say("Enabling Integration Service...")
|
|
|
|
|
|
|
|
vmName := state.Get("vmName").(string)
|
|
|
|
s.name = "Guest Service Interface"
|
|
|
|
|
2015-10-30 04:23:30 -04:00
|
|
|
err := driver.EnableVirtualMachineIntegrationService(vmName, s.name)
|
2015-06-21 07:36:07 -04:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
err := fmt.Errorf("Error enabling Integration Service: %s", err)
|
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepEnableIntegrationService) Cleanup(state multistep.StateBag) {
|
|
|
|
// do nothing
|
|
|
|
}
|