Add a new option vmID

This allow to create a LXC container with a specific ID
This commit is contained in:
Anthony Callegaro 2020-02-05 22:26:25 +01:00
parent 7ac3724eff
commit 66b08f058c
1 changed files with 14 additions and 3 deletions

View File

@ -298,6 +298,11 @@ func resourceLxc() *schema.Resource {
Required: true,
ForceNew: true,
},
"vmid": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
},
}
}
@ -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)