Compare commits

..

No commits in common. "cfe445a761086615bb89d37106301ce71f0e735a" and "8c17f720c868838244f7a5522a3f1315d5b4a190" have entirely different histories.

5 changed files with 26 additions and 327 deletions

View File

@ -14,9 +14,3 @@ data "ganeti_networks" "all" {}
output "all_networks" {
value = data.ganeti_networks.all.networks
}
data "ganeti_instances" "all" {}
output "instance" {
value = data.ganeti_instances.all.instances
}

View File

@ -1,242 +0,0 @@
package ganeti
import (
"context"
rapi "burntworld.ca/go-rapi-client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceInstance() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceInstanceRead,
Schema: map[string]*schema.Schema{
"instances": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_usage": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"oper_vcpus": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"network_port": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"serial_no": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"ctime": &schema.Schema{
Type: schema.TypeFloat,
Computed: true,
},
"mtime": &schema.Schema{
Type: schema.TypeFloat,
Computed: true,
},
"oper_state": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
},
"disk_template": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"status": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"oper_ram": &schema.Schema{
Type: schema.TypeInt,
Computed: true,
},
"pnode": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"admin_state": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"os": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"nic.uuids": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic_modes": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.names": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.networks.names": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk.spindles": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk.uuids": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk.sizes": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"tags": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.networks": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.macs": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString
},
},
"nic.bridges": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.ips": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"nic.links": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Deprecated: "to satisfy terraform?",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"snodes": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"hvparams": &schema.Schema{
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"beparams": &schema.Schema{
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"custom_hvparams": &schema.Schema{
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"custom_beparams": &schema.Schema{
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"custom_nicparams": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
},
},
}
}
func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics
client := m.(*rapi.Client)
instances, err := client.GetInstancesBulk()
if err != nil {
return diag.FromErr(err)
}
if err = d.Set("instances", instances); err != nil {
return diag.FromErr(err)
}
return diags;
}

View File

@ -8,6 +8,7 @@ import (
rapi "burntworld.ca/go-rapi-client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceNetworks() *schema.Resource {
@ -47,12 +48,9 @@ func dataSourceNetworks() *schema.Resource {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema {
Type: schema.TypeList,
Elemb: &schema.Schema{
Type: schema.TypeString,
},
},
},
"inst_list": &schema.Schema{
Type: schema.TypeList,
Computed: true,

View File

@ -42,7 +42,6 @@ func Provider() *schema.Provider {
ConfigureContextFunc: providerConfigure,
DataSourcesMap: map[string]*schema.Resource {
"ganeti_networks": dataSourceNetworks(),
"ganeti_instances": dataSourceInstance(),
},
ResourcesMap: map[string]*schema.Resource{},
}

View File

@ -1,50 +0,0 @@
package ganeti
import (
"context"
rapi "burntworld.ca/go-rapi-client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceInstance() *schema.Resource {
return &schema.Resource{
CreateContext: resourceInstanceCreate,
ReadContext: resourceInstanceRead,
UpdateContext: resourceInstanceUpdate,
DeleteContext: resourceInstanceDelete,
}
}
func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
return diags
}
func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
client := m.(*rapi.Client)
instances, err := client.GetInstancesBulk()
if err != nil {
return diag.FromErr(err)
}
if err = d.Set("instances", instances); err != nil {
return diag.FromErr(err)
}
return diags
}
func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return resourceInstanceRead(ctx, d, m)
}
func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
return diags
}