mirror of
https://github.com/letic/terraform-provider-proxmox.git
synced 2024-10-03 01:01:05 +00:00
get the target_node for read
This commit is contained in:
parent
74fdcb9bd7
commit
4c6ca729d5
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
pxapi "github.com/Telmate/proxmox-api-go/proxmox"
|
pxapi "github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"log"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,10 +16,6 @@ func resourceVmQemu() *schema.Resource {
|
|||||||
Delete: resourceVmQemuDelete,
|
Delete: resourceVmQemuDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
// "vmid": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Optional: true,
|
|
||||||
// },
|
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
@ -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())
|
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)
|
maxid, err := pxapi.MaxVmId(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Println("MaxVmId: %d", maxid)
|
|
||||||
// d.Set("vmid", maxid+1)
|
|
||||||
// }
|
|
||||||
vmr := pxapi.NewVmRef(maxid + 1)
|
vmr := pxapi.NewVmRef(maxid + 1)
|
||||||
vmr.SetNode(d.Get("target_node").(string))
|
vmr.SetNode(d.Get("target_node").(string))
|
||||||
|
|
||||||
@ -184,7 +176,7 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.SetId(strconv.Itoa(vmr.VmId()))
|
d.SetId(strconv.Itoa(vmr.VmId()))
|
||||||
//d.Set("vmid", vmr.VmId())
|
d.Set("target_node", vmr.Node())
|
||||||
d.Set("name", config.Name)
|
d.Set("name", config.Name)
|
||||||
d.Set("desc", config.Description)
|
d.Set("desc", config.Description)
|
||||||
d.Set("storage", config.Storage)
|
d.Set("storage", config.Storage)
|
||||||
|
Loading…
Reference in New Issue
Block a user