Skip to content

Commit

Permalink
switch to /cluster/nextid instead of maxid
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Gongaware committed Jul 11, 2018
1 parent 90d504f commit 9291c20
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions proxmox/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9291c20

Please sign in to comment.