-
Notifications
You must be signed in to change notification settings - Fork 0
/
step_run.go
36 lines (28 loc) · 878 Bytes
/
step_run.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
package vmm
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
)
type stepRun struct {
vmName string
diskPath string
diskFormat string
memSize string
}
func (step *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
driver := state.Get("driver").(Driver)
isoPath := state.Get("iso_path").(string)
args := []string{"-c", "-L", "-d", isoPath, "-d", step.diskFormat + ":" + step.diskPath, "-m", step.memSize}
ui.Say("Starting VMM instance " + step.vmName)
if err := driver.Start(step.vmName, args...); err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (step *stepRun) Cleanup(state multistep.StateBag) {
driver := state.Get("driver").(Driver)
driver.Stop(step.vmName)
}