Add a new option vmID
This allow to create a LXC container with a specific ID
This commit is contained in:
parent
7ac3724eff
commit
66b08f058c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue