-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovider.go
61 lines (51 loc) · 1.52 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package odl
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"server_ip": {
Type: schema.TypeString,
Required: true,
Description: "odl server ip",
DefaultFunc: schema.EnvDefaultFunc("ODL_SERVER_IP", nil),
},
"port": {
Type: schema.TypeInt,
Required: true,
Description: "odl server port",
DefaultFunc: schema.EnvDefaultFunc("ODL_SERVER_PORT", nil),
},
"user_name": {
Type: schema.TypeString,
Required: true,
Description: "odl user name",
DefaultFunc: schema.EnvDefaultFunc("ODL_SERVER_USER", nil),
},
"user_password": {
Type: schema.TypeString,
Required: true,
Sensitive: true,
Description: "odl user password",
DefaultFunc: schema.EnvDefaultFunc("ODL_SERVER_PASSWORD", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"odl_virtual_tenant_network": resourceOdlVirtualTenantNetwork(),
"odl_virtual_bridge": resourceOdlVirtualBridge(),
"odl_virtual_interface": resourceOdlVirtualInterface(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
ServerIP: d.Get("server_ip").(string),
Port: d.Get("port").(int),
Username: d.Get("user_name").(string),
Password: d.Get("user_password").(string),
}
return config.checkConnection()
}