-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovider.go
executable file
·57 lines (50 loc) · 1.4 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
package nsx
import (
"log"
"os"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider for NSX
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Required: true,
Description: "NSX Server Port",
DefaultFunc: schema.EnvDefaultFunc("NSX_SERVER_PORT", nil),
},
"nsx_username": {
Type: schema.TypeString,
Required: true,
Description: "NSX username",
DefaultFunc: schema.EnvDefaultFunc("NSX_SERVER_USERNAME", nil),
},
"nsx_password": {
Type: schema.TypeString,
Required: true,
Description: "NSX Password for provided user_name",
DefaultFunc: schema.EnvDefaultFunc("NSX_SERVER_PASSWORD", nil),
},
"nsx_server_ip": {
Type: schema.TypeString,
Required: true,
Description: "NSX Server IP Address",
DefaultFunc: schema.EnvDefaultFunc("NSX_SERVER_IP", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"nsx_add_virtual_machine_security_group": resourceNsxAddVirtualMachineSecurityGroup(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config, err := NsxConfig(d)
if err != nil {
log.Println("[ERROR] no connection was established with nsx server.")
os.Exit(1)
}
return config, nil
}