parent
0d454f19bd
commit
e503afb9da
|
@ -1,4 +1,4 @@
|
||||||
//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig
|
//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig
|
||||||
|
|
||||||
package proxmox
|
package proxmox
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ type Config struct {
|
||||||
CPUType string `mapstructure:"cpu_type"`
|
CPUType string `mapstructure:"cpu_type"`
|
||||||
Sockets int `mapstructure:"sockets"`
|
Sockets int `mapstructure:"sockets"`
|
||||||
OS string `mapstructure:"os"`
|
OS string `mapstructure:"os"`
|
||||||
|
VGA vgaConfig `mapstructure:"vga"`
|
||||||
NICs []nicConfig `mapstructure:"network_adapters"`
|
NICs []nicConfig `mapstructure:"network_adapters"`
|
||||||
Disks []diskConfig `mapstructure:"disks"`
|
Disks []diskConfig `mapstructure:"disks"`
|
||||||
ISOFile string `mapstructure:"iso_file"`
|
ISOFile string `mapstructure:"iso_file"`
|
||||||
|
@ -75,6 +76,10 @@ type diskConfig struct {
|
||||||
CacheMode string `mapstructure:"cache_mode"`
|
CacheMode string `mapstructure:"cache_mode"`
|
||||||
DiskFormat string `mapstructure:"format"`
|
DiskFormat string `mapstructure:"format"`
|
||||||
}
|
}
|
||||||
|
type vgaConfig struct {
|
||||||
|
Type string `mapstructure:"type"`
|
||||||
|
Memory int `mapstructure:"memory"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
// Agent defaults to true
|
// Agent defaults to true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig"; DO NOT EDIT.
|
// Code generated by "mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig"; DO NOT EDIT.
|
||||||
package proxmox
|
package proxmox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -84,6 +84,7 @@ type FlatConfig struct {
|
||||||
CPUType *string `mapstructure:"cpu_type" cty:"cpu_type"`
|
CPUType *string `mapstructure:"cpu_type" cty:"cpu_type"`
|
||||||
Sockets *int `mapstructure:"sockets" cty:"sockets"`
|
Sockets *int `mapstructure:"sockets" cty:"sockets"`
|
||||||
OS *string `mapstructure:"os" cty:"os"`
|
OS *string `mapstructure:"os" cty:"os"`
|
||||||
|
VGA *FlatvgaConfig `mapstructure:"vga" cty:"vga"`
|
||||||
NICs []FlatnicConfig `mapstructure:"network_adapters" cty:"network_adapters"`
|
NICs []FlatnicConfig `mapstructure:"network_adapters" cty:"network_adapters"`
|
||||||
Disks []FlatdiskConfig `mapstructure:"disks" cty:"disks"`
|
Disks []FlatdiskConfig `mapstructure:"disks" cty:"disks"`
|
||||||
ISOFile *string `mapstructure:"iso_file" cty:"iso_file"`
|
ISOFile *string `mapstructure:"iso_file" cty:"iso_file"`
|
||||||
|
@ -182,6 +183,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||||
"cpu_type": &hcldec.AttrSpec{Name: "cpu_type", Type: cty.String, Required: false},
|
"cpu_type": &hcldec.AttrSpec{Name: "cpu_type", Type: cty.String, Required: false},
|
||||||
"sockets": &hcldec.AttrSpec{Name: "sockets", Type: cty.Number, Required: false},
|
"sockets": &hcldec.AttrSpec{Name: "sockets", Type: cty.Number, Required: false},
|
||||||
"os": &hcldec.AttrSpec{Name: "os", Type: cty.String, Required: false},
|
"os": &hcldec.AttrSpec{Name: "os", Type: cty.String, Required: false},
|
||||||
|
"vga": &hcldec.BlockSpec{TypeName: "vga", Nested: hcldec.ObjectSpec((*FlatvgaConfig)(nil).HCL2Spec())},
|
||||||
"network_adapters": &hcldec.BlockListSpec{TypeName: "network_adapters", Nested: hcldec.ObjectSpec((*FlatnicConfig)(nil).HCL2Spec())},
|
"network_adapters": &hcldec.BlockListSpec{TypeName: "network_adapters", Nested: hcldec.ObjectSpec((*FlatnicConfig)(nil).HCL2Spec())},
|
||||||
"disks": &hcldec.BlockListSpec{TypeName: "disks", Nested: hcldec.ObjectSpec((*FlatdiskConfig)(nil).HCL2Spec())},
|
"disks": &hcldec.BlockListSpec{TypeName: "disks", Nested: hcldec.ObjectSpec((*FlatdiskConfig)(nil).HCL2Spec())},
|
||||||
"iso_file": &hcldec.AttrSpec{Name: "iso_file", Type: cty.String, Required: false},
|
"iso_file": &hcldec.AttrSpec{Name: "iso_file", Type: cty.String, Required: false},
|
||||||
|
@ -256,3 +258,28 @@ func (*FlatnicConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FlatvgaConfig is an auto-generated flat version of vgaConfig.
|
||||||
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
type FlatvgaConfig struct {
|
||||||
|
Type *string `mapstructure:"type" cty:"type"`
|
||||||
|
Memory *int `mapstructure:"memory" cty:"memory"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlatMapstructure returns a new FlatvgaConfig.
|
||||||
|
// FlatvgaConfig is an auto-generated flat version of vgaConfig.
|
||||||
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
func (*vgaConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatvgaConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HCL2Spec returns the hcl spec of a vgaConfig.
|
||||||
|
// This spec is used by HCL to read the fields of vgaConfig.
|
||||||
|
// The decoded values from this spec will then be applied to a FlatvgaConfig.
|
||||||
|
func (*FlatvgaConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||||
|
s := map[string]hcldec.Spec{
|
||||||
|
"type": &hcldec.AttrSpec{Name: "type", Type: cty.String, Required: false},
|
||||||
|
"memory": &hcldec.AttrSpec{Name: "memory", Type: cty.Number, Required: false},
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
|
||||||
QemuCores: c.Cores,
|
QemuCores: c.Cores,
|
||||||
QemuSockets: c.Sockets,
|
QemuSockets: c.Sockets,
|
||||||
QemuOs: c.OS,
|
QemuOs: c.OS,
|
||||||
|
QemuVga: generateProxmoxVga(c.VGA),
|
||||||
QemuIso: isoFile,
|
QemuIso: isoFile,
|
||||||
QemuNetworks: generateProxmoxNetworkAdapters(c.NICs),
|
QemuNetworks: generateProxmoxNetworkAdapters(c.NICs),
|
||||||
QemuDisks: generateProxmoxDisks(c.Disks),
|
QemuDisks: generateProxmoxDisks(c.Disks),
|
||||||
|
@ -118,6 +119,15 @@ func generateProxmoxDisks(disks []diskConfig) proxmox.QemuDevices {
|
||||||
}
|
}
|
||||||
return devs
|
return devs
|
||||||
}
|
}
|
||||||
|
func generateProxmoxVga(vga vgaConfig) proxmox.QemuDevice {
|
||||||
|
dev := make(proxmox.QemuDevice)
|
||||||
|
setDeviceParamIfDefined(dev, "type", vga.Type)
|
||||||
|
|
||||||
|
if vga.Memory > 0 {
|
||||||
|
dev["memory"] = vga.Memory
|
||||||
|
}
|
||||||
|
return dev
|
||||||
|
}
|
||||||
|
|
||||||
func setDeviceParamIfDefined(dev proxmox.QemuDevice, key, value string) {
|
func setDeviceParamIfDefined(dev proxmox.QemuDevice, key, value string) {
|
||||||
if value != "" {
|
if value != "" {
|
||||||
|
|
|
@ -95,6 +95,21 @@ builder.
|
||||||
`wvista`, `win7`, `win8`, `win10`, `l24` (Linux 2.4), `l26` (Linux 2.6+),
|
`wvista`, `win7`, `win8`, `win10`, `l24` (Linux 2.4), `l26` (Linux 2.6+),
|
||||||
`solaris` or `other`. Defaults to `other`.
|
`solaris` or `other`. Defaults to `other`.
|
||||||
|
|
||||||
|
- `vga` (object) - The graphics adapter to use. Example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "vmware",
|
||||||
|
"memory": 32
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `type` (string) - Can be `cirrus`, `none`, `qxl`,`qxl2`, `qxl3`,
|
||||||
|
`qxl4`, `serial0`, `serial1`, `serial2`, `serial3`, `std`, `virtio`, `vmware`.
|
||||||
|
Defaults to `std`.
|
||||||
|
|
||||||
|
- `memory` (int) - How much memory to assign.
|
||||||
|
|
||||||
- `network_adapters` (array of objects) - Network adapters attached to the
|
- `network_adapters` (array of objects) - Network adapters attached to the
|
||||||
virtual machine. Example:
|
virtual machine. Example:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue