forked from hashicorp/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step_create_disk.go
38 lines (32 loc) · 916 Bytes
/
step_create_disk.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
37
38
package vmware
import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"path/filepath"
)
// This step creates the virtual disks for the VM.
//
// Uses:
// config *config
// driver Driver
// ui packer.Ui
//
// Produces:
// <nothing>
type stepCreateDisk struct{}
func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction {
config := state["config"].(*config)
driver := state["driver"].(Driver)
ui := state["ui"].(packer.Ui)
ui.Say("Creating virtual machine disk")
output := filepath.Join(config.OutputDir, config.DiskName+".vmdk")
if err := driver.CreateDisk(output, fmt.Sprintf("%dM", config.DiskSize)); err != nil {
err := fmt.Errorf("Error creating disk: %s", err)
state["error"] = err
ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (stepCreateDisk) Cleanup(map[string]interface{}) {}