-
Notifications
You must be signed in to change notification settings - Fork 98
/
data_source_aci_fvnsvsaninstp.go
63 lines (47 loc) · 1.32 KB
/
data_source_aci_fvnsvsaninstp.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
package aci
import (
"context"
"fmt"
"github.com/ciscoecosystem/aci-go-client/v2/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceAciVSANPool() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAciVSANPoolRead,
SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"alloc_mode": &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"dynamic",
"static",
}, false),
},
"name_alias": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
}),
}
}
func dataSourceAciVSANPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)
name := d.Get("name").(string)
allocMode := d.Get("alloc_mode").(string)
rn := fmt.Sprintf("infra/vsanns-[%s]-%s", name, allocMode)
dn := fmt.Sprintf("uni/%s", rn)
fvnsVsanInstP, err := getRemoteVSANPool(aciClient, dn)
if err != nil {
return diag.FromErr(err)
}
setVSANPoolAttributes(fvnsVsanInstP, d)
return nil
}