2015-10-06 05:53:07 +02:00
|
|
|
package vsphere
|
|
|
|
|
|
|
|
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("VSPHERE_USER", nil),
|
|
|
|
Description: "The user name for vSphere API operations.",
|
|
|
|
},
|
|
|
|
|
|
|
|
"password": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_PASSWORD", nil),
|
|
|
|
Description: "The user password for vSphere API operations.",
|
|
|
|
},
|
|
|
|
|
2015-11-01 15:07:23 +01:00
|
|
|
"vsphere_server": &schema.Schema{
|
2015-10-06 05:53:07 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
2015-11-01 15:07:23 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_SERVER", nil),
|
|
|
|
Description: "The vSphere Server name for vSphere API operations.",
|
2015-10-06 05:53:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
|
|
"vsphere_virtual_machine": resourceVSphereVirtualMachine(),
|
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
User: d.Get("user").(string),
|
|
|
|
Password: d.Get("password").(string),
|
2015-11-01 15:07:23 +01:00
|
|
|
VSphereServer: d.Get("vsphere_server").(string),
|
2015-10-06 05:53:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|