Skip to content

Commit

Permalink
Add a new option vmID
Browse files Browse the repository at this point in the history
This allow to create a LXC container with a specific ID
  • Loading branch information
Anthony Callegaro committed Feb 5, 2020
1 parent 7ac3724 commit 66b08f0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions proxmox/resource_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ func resourceLxc() *schema.Resource {
Required: true,
ForceNew: true,
},
"vmid": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
},
}
}
Expand Down Expand Up @@ -377,10 +382,16 @@ func resourceLxcCreate(d *schema.ResourceData, meta interface{}) error {

// get unique id
nextid, err := nextVmId(pconf)
if err != nil {
pmParallelEnd(pconf)
return err
vmID := d.Get("vmid").(int)
if vmID != 0 {
nextid = vmID
} else {
if err != nil {
pmParallelEnd(pconf)
return err
}
}

vmr := pxapi.NewVmRef(nextid)
vmr.SetNode(targetNode)
err = config.CreateLxc(vmr, client)
Expand Down

0 comments on commit 66b08f0

Please sign in to comment.