Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Paranoiaque committed Aug 13, 2019
2 parents f0a71f4 + 68c41fc commit 322ba75
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ resource "proxmox_vm_qemu" "prepprovision-test" {
sockets = 1
memory = 2560
scsihw = "lsi"
# Boot from hard disk (c), CD-ROM (d), network (n)
boot = "cdn"
# Default boot disk
bootdisk = "virtio0"
network {
id = 0
model = "virtio"
Expand All @@ -140,6 +144,12 @@ resource "proxmox_vm_qemu" "prepprovision-test" {
size = 4G
backup = true
}
# Serial interface of type socket is used by xterm.js
# You will need to configure your guest system before being able to use it
serial {
id = 0
type = "socket"
}
preprovision = true
ssh_forward_ip = "10.0.0.1"
ssh_user = "terraform"
Expand Down
26 changes: 26 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ func resourceVmQemu() *schema.Resource {
return strings.TrimSpace(old) == strings.TrimSpace(new)
},
},
"serial": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
Type: schema.TypeInt,
Required: true,
},
"type": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
},
},
},
"os_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -390,6 +406,8 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
qemuNetworks := DevicesSetToMap(networks)
disks := d.Get("disk").(*schema.Set)
qemuDisks := DevicesSetToMap(disks)
serials := d.Get("serial").(*schema.Set)
qemuSerials := DevicesSetToMap(serials)

config := pxapi.ConfigQemu{
Name: vmName,
Expand All @@ -408,6 +426,7 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
QemuOs: d.Get("qemu_os").(string),
QemuNetworks: qemuNetworks,
QemuDisks: qemuDisks,
QemuSerials: qemuSerials,
// Cloud-init.
CIuser: d.Get("ciuser").(string),
CIpassword: d.Get("cipassword").(string),
Expand Down Expand Up @@ -552,6 +571,8 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
qemuDisks := DevicesSetToMap(configDisksSet)
configNetworksSet := d.Get("network").(*schema.Set)
qemuNetworks := DevicesSetToMap(configNetworksSet)
serials := d.Get("serial").(*schema.Set)
qemuSerials := DevicesSetToMap(serials)

config := pxapi.ConfigQemu{
Name: d.Get("name").(string),
Expand All @@ -570,6 +591,7 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
QemuOs: d.Get("qemu_os").(string),
QemuNetworks: qemuNetworks,
QemuDisks: qemuDisks,
QemuSerials: qemuSerials,
// Cloud-init.
CIuser: d.Get("ciuser").(string),
CIpassword: d.Get("cipassword").(string),
Expand Down Expand Up @@ -688,6 +710,10 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error {
d.Set("vlan", config.QemuVlanTag)
d.Set("mac", config.QemuMacAddr)
d.Set("pool", vmr.Pool())
//Serials
configSerialsSet := d.Get("serial").(*schema.Set)
activeSerialSet := UpdateDevicesSet(configSerialsSet, config.QemuSerials)
d.Set("serial", activeSerialSet)

pmParallelEnd(pconf)
return nil
Expand Down

0 comments on commit 322ba75

Please sign in to comment.