From 821ceb8d0d7955b12dc8ea4c20144c16aa8a695b Mon Sep 17 00:00:00 2001 From: Grant Gongaware Date: Wed, 11 Jul 2018 15:14:26 -0700 Subject: [PATCH] switch to /cluster/nextid instead of maxid --- proxmox/provider.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/proxmox/provider.go b/proxmox/provider.go index 960777f..a3d6fa1 100644 --- a/proxmox/provider.go +++ b/proxmox/provider.go @@ -76,7 +76,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { Client: client, MaxParallel: d.Get("pm_parallel").(int), CurrentParallel: 0, - MaxVmId: 0, + MaxVmId: -1, Mutex: &mut, Cond: sync.NewCond(&mut), }, nil @@ -97,13 +97,10 @@ func getClient(pm_api_url string, pm_user string, pm_password string, pm_tls_ins func nextVmId(pconf *providerConfiguration) (nextId int, err error) { pconf.Mutex.Lock() - if pconf.MaxVmId == 0 { - pconf.MaxVmId, err = pxapi.MaxVmId(pconf.Client) - if err != nil { - return 0, err - } + pconf.MaxVmId, err = pconf.Client.GetNextID(pconf.MaxVmId + 1) + if err != nil { + return 0, err } - pconf.MaxVmId++ nextId = pconf.MaxVmId pconf.Mutex.Unlock() return nextId, nil