From 66b08f058ca1afc751ee922dc574924846400803 Mon Sep 17 00:00:00 2001 From: Anthony Callegaro Date: Wed, 5 Feb 2020 22:26:25 +0100 Subject: [PATCH] Add a new option vmID This allow to create a LXC container with a specific ID --- proxmox/resource_lxc.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/proxmox/resource_lxc.go b/proxmox/resource_lxc.go index 38b8b3d7..d8dbc5d1 100644 --- a/proxmox/resource_lxc.go +++ b/proxmox/resource_lxc.go @@ -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)