From b734e7888fbe5d87bf7a5da10f32299c704ea12f Mon Sep 17 00:00:00 2001 From: Andreas Gruhler Date: Sun, 14 Jul 2019 01:48:45 +0200 Subject: [PATCH 1/2] add pool to qemu resource --- proxmox/resource_vm_qemu.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index c915af9..183168b 100644 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -342,6 +342,10 @@ func resourceVmQemu() *schema.Resource { Default: true, ConflictsWith: []string{"ssh_forward_ip", "ssh_user", "ssh_private_key", "os_type", "os_network_config"}, }, + "pool": { + Type: schema.TypeString, + Optional: true, + }, }, } } @@ -391,6 +395,7 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error { forceCreate := d.Get("force_create").(bool) targetNode := d.Get("target_node").(string) + pool := d.Get("pool").(string) if dupVmr != nil && forceCreate { pmParallelEnd(pconf) @@ -411,7 +416,12 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error { } vmr = pxapi.NewVmRef(nextid) + // set target node and pool vmr.SetNode(targetNode) + if pool != "" { + vmr.SetPool(pool) + } + // check if ISO or clone if d.Get("clone").(string) != "" { sourceVmr, err := client.GetVmRefByName(d.Get("clone").(string)) @@ -630,6 +640,7 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error { d.Set("bridge", config.QemuBrige) d.Set("vlan", config.QemuVlanTag) d.Set("mac", config.QemuMacAddr) + d.Set("pool", vmr.Pool()) pmParallelEnd(pconf) return nil From ff059028ba7295b82abab8a74ef006fd05feac6f Mon Sep 17 00:00:00 2001 From: Andreas Gruhler Date: Sun, 14 Jul 2019 01:49:34 +0200 Subject: [PATCH 2/2] document pool parameter for qemu resource --- README.md | 8 ++++++++ examples/cloudinit_example.tf | 3 +++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index ade8b2c..34e9e1c 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ resource "proxmox_vm_qemu" "cloudinit-test" { target_node = "proxmox1-xx" clone = "ci-ubuntu-template" + + # The destination resource pool for the new VM + pool = "pool0" + storage = "local" cores = 3 sockets = 1 @@ -105,6 +109,10 @@ resource "proxmox_vm_qemu" "prepprovision-test" { target_node = "proxmox1-xx" clone = "terraform-ubuntu1404-template" + + # The destination resource pool for the new VM + pool = "pool0" + cores = 3 sockets = 1 memory = 2560 diff --git a/examples/cloudinit_example.tf b/examples/cloudinit_example.tf index e2ac114..32f4e3b 100644 --- a/examples/cloudinit_example.tf +++ b/examples/cloudinit_example.tf @@ -13,6 +13,9 @@ resource "proxmox_vm_qemu" "cloudinit-test" { # this might not include the FQDN target_node = "proxmox-server02" + # The destination resource pool for the new VM + pool = "pool0" + # The template name to clone this vm from clone = "linux-cloudinit-template"