Skip to content

Commit

Permalink
Add option to define the VM display
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Paranoiaque committed Dec 13, 2019
1 parent db600b5 commit 0d1d81b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ func resourceVmQemu() *schema.Resource {
Optional: true,
Default: "",
},
"vga": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Optional: true,
Default: "std",
},
"memory": {
Type: schema.TypeInt,
Optional: true,
},
},
},
},
"network": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -433,6 +450,8 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
pmParallelBegin(pconf)
client := pconf.Client
vmName := d.Get("name").(string)
vga := d.Get("vga").(*schema.Set)
qemuVgaList := vga.List()
networks := d.Get("network").(*schema.Set)
qemuNetworks := DevicesSetToMap(networks)
disks := d.Get("disk").(*schema.Set)
Expand Down Expand Up @@ -479,6 +498,9 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
QemuVlanTag: d.Get("vlan").(int),
QemuMacAddr: d.Get("mac").(string),
}
if len(qemuVgaList) > 0 {
config.QemuVga = qemuVgaList[0].(map[string]interface{})
}
log.Print("[DEBUG] checking for duplicate name")
dupVmr, _ := client.GetVmRefByName(vmName)

Expand Down Expand Up @@ -614,6 +636,8 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
}
configDisksSet := d.Get("disk").(*schema.Set)
qemuDisks := DevicesSetToMap(configDisksSet)
vga := d.Get("vga").(*schema.Set)
qemuVgaList := vga.List()
configNetworksSet := d.Get("network").(*schema.Set)
qemuNetworks := DevicesSetToMap(configNetworksSet)
serials := d.Get("serial").(*schema.Set)
Expand Down Expand Up @@ -670,6 +694,9 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
QemuVlanTag: d.Get("vlan").(int),
QemuMacAddr: d.Get("mac").(string),
}
if len(qemuVgaList) > 0 {
config.QemuVga = qemuVgaList[0].(map[string]interface{})
}

err = config.UpdateConfig(vmr, client)
if err != nil {
Expand Down Expand Up @@ -761,6 +788,11 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error {
configDisksSet := d.Get("disk").(*schema.Set)
activeDisksSet := UpdateDevicesSet(configDisksSet, config.QemuDisks)
d.Set("disk", activeDisksSet)
// Display.
activeVgaSet := d.Get("vga").(*schema.Set)
if len(activeVgaSet.List()) > 0 {
d.Set("features", UpdateDeviceConfDefaults(config.QemuVga, activeVgaSet))
}
// Networks.
configNetworksSet := d.Get("network").(*schema.Set)
activeNetworksSet := UpdateDevicesSet(configNetworksSet, config.QemuNetworks)
Expand Down

0 comments on commit 0d1d81b

Please sign in to comment.