This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
provider.go
72 lines (61 loc) · 1.85 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
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"github.com/CiscoUcs/UCS-Terraform/ucsclient"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"ip_address": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "UCS Manager IP address or CIMC IP address.",
},
"username": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The user's name to access the UCS Management.",
},
"password": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The password to access the UCS Management.",
},
"tslinsecureskipverify": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "The TSL insecure skip verify",
},
"log_level": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The log level",
},
"log_filename": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "The log filename",
},
},
ResourcesMap: map[string]*schema.Resource{
"ucs_service_profile": resourceUcsServiceProfile(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := ucsclient.Config{
AppName: "UCS",
IpAddress: d.Get("ip_address").(string),
Username: d.Get("username").(string),
Password: d.Get("password").(string),
TslInsecureSkipVerify: d.Get("tslinsecureskipverify").(bool),
LogFilename: d.Get("log_filename").(string),
LogLevel: d.Get("log_level").(int),
}
return config.Client(), nil
}