2015-10-26 15:45:48 +01:00
|
|
|
package vcd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"user": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_USER", nil),
|
|
|
|
Description: "The user name for vcd API operations.",
|
|
|
|
},
|
|
|
|
|
|
|
|
"password": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_PASSWORD", nil),
|
|
|
|
Description: "The user password for vcd API operations.",
|
|
|
|
},
|
|
|
|
|
|
|
|
"org": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_ORG", nil),
|
|
|
|
Description: "The vcd org for API operations",
|
|
|
|
},
|
|
|
|
|
|
|
|
"url": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_URL", nil),
|
|
|
|
Description: "The vcd url for vcd API operations.",
|
|
|
|
},
|
2015-11-19 00:56:17 +01:00
|
|
|
|
2015-10-26 15:45:48 +01:00
|
|
|
"vdc": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_VDC", ""),
|
|
|
|
Description: "The name of the VDC to run operations on",
|
|
|
|
},
|
2015-11-19 00:56:17 +01:00
|
|
|
|
|
|
|
"maxRetryTimeout": &schema.Schema{
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
2015-11-23 12:45:16 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VCD_MAX_RETRY_TIMEOUT", 60),
|
|
|
|
Description: "Max num seconds to wait for successful response when operating on resources within vCloud (defaults to 60)",
|
2015-11-19 00:56:17 +01:00
|
|
|
},
|
2015-10-26 15:45:48 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
|
|
"vcd_network": resourceVcdNetwork(),
|
|
|
|
"vcd_vapp": resourceVcdVApp(),
|
|
|
|
"vcd_firewall_rules": resourceVcdFirewallRules(),
|
|
|
|
"vcd_dnat": resourceVcdDNAT(),
|
|
|
|
"vcd_snat": resourceVcdSNAT(),
|
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
2015-12-07 22:24:34 +01:00
|
|
|
User: d.Get("user").(string),
|
|
|
|
Password: d.Get("password").(string),
|
|
|
|
Org: d.Get("org").(string),
|
|
|
|
Href: d.Get("url").(string),
|
|
|
|
VDC: d.Get("vdc").(string),
|
2015-11-19 00:56:17 +01:00
|
|
|
MaxRetryTimeout: d.Get("maxRetryTimeout").(int),
|
2015-10-26 15:45:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|