Skip to content

Commit

Permalink
give more time for proxmox to catchup on updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Gongaware committed Jul 21, 2017
1 parent 365b131 commit a2393a7
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,28 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
QemuVlanTag: d.Get("vlan").(int),
}

config.UpdateConfig(vmr, client)
err = config.UpdateConfig(vmr, client)
if err != nil {
pmParallelEnd(pconf)
return err
}

// give sometime to proxmox to catchup
time.Sleep(5 * time.Second)

prepareDiskSize(client, vmr, disk_gb)

// give sometime to proxmox to catchup
time.Sleep(5 * time.Second)

log.Print("[DEBUG] starting VM")
_, err = client.StartVm(vmr)

if err != nil {
pmParallelEnd(pconf)
return err
}

sshPort, err := pxapi.SshForwardUsernet(vmr, client)
if err != nil {
pmParallelEnd(pconf)
Expand All @@ -317,6 +335,9 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error {
"private_key": d.Get("ssh_private_key").(string),
})
pmParallelEnd(pconf)

// give sometime to bootup
time.Sleep(9 * time.Second)
return nil
}

Expand Down Expand Up @@ -376,7 +397,9 @@ func resourceVmQemuDelete(d *schema.ResourceData, meta interface{}) error {

func prepareDiskSize(client *pxapi.Client, vmr *pxapi.VmRef, disk_gb float64) error {
clonedConfig, err := pxapi.NewConfigQemuFromApi(vmr, client)

if err != nil {
return err
}
if disk_gb > clonedConfig.DiskSize {
log.Print("[DEBUG] resizing disk")
_, err = client.ResizeQemuDisk(vmr, "virtio0", int(disk_gb-clonedConfig.DiskSize))
Expand Down

0 comments on commit a2393a7

Please sign in to comment.