Skip to content

Commit

Permalink
get the target_node for read
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Gongaware committed Feb 10, 2017
1 parent 74fdcb9 commit 4c6ca72
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
pxapi "github.com/Telmate/proxmox-api-go/proxmox"
"github.com/hashicorp/terraform/helper/schema"
"log"
"strconv"
)

Expand All @@ -17,10 +16,6 @@ func resourceVmQemu() *schema.Resource {
Delete: resourceVmQemuDelete,

Schema: map[string]*schema.Schema{
// "vmid": {
// Type: schema.TypeInt,
// Optional: true,
// },
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -117,14 +112,11 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Duplicate VM name (%s) with vmId: %d", vmName, dupVmr.VmId())
}

// if d.Get("vmid").(int) == 0 {
// get unique id
maxid, err := pxapi.MaxVmId(client)
if err != nil {
return err
}
log.Println("MaxVmId: %d", maxid)
// d.Set("vmid", maxid+1)
// }
vmr := pxapi.NewVmRef(maxid + 1)
vmr.SetNode(d.Get("target_node").(string))

Expand Down Expand Up @@ -184,7 +176,7 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error {
return err
}
d.SetId(strconv.Itoa(vmr.VmId()))
//d.Set("vmid", vmr.VmId())
d.Set("target_node", vmr.Node())
d.Set("name", config.Name)
d.Set("desc", config.Description)
d.Set("storage", config.Storage)
Expand Down

0 comments on commit 4c6ca72

Please sign in to comment.