Skip to content

Commit

Permalink
Merge pull request #122 from terraform-providers/CACIT-68-69
Browse files Browse the repository at this point in the history
Cacit 68 69
  • Loading branch information
nkatarmal-crest authored Sep 21, 2020
2 parents b4a3853 + 6063c77 commit 8a5d784
Show file tree
Hide file tree
Showing 16 changed files with 414 additions and 87 deletions.
82 changes: 82 additions & 0 deletions aci/data_source_aci_fabricpathep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package aci

import (
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/ciscoecosystem/aci-go-client/models"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceAciFabricPathEndpoint() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciFabricPathEndpointRead,

SchemaVersion: 1,

Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
"pod_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
},

"node_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
},

"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
}),
}
}

func getRemoteFabricPathEndpoint(client *client.Client, dn string) (*models.FabricPathEndpoint, error) {
fabricPathEpCont, err := client.Get(dn)
if err != nil {
return nil, err
}

fabricPathEp := models.FabricPathEndpointFromContainer(fabricPathEpCont)

if fabricPathEp.DistinguishedName == "" {
return nil, fmt.Errorf("FabricPathEndpoint %s not found", fabricPathEp.DistinguishedName)
}

return fabricPathEp, nil
}

func setFabricPathEndpointAttributes(fabricPathEp *models.FabricPathEndpoint, d *schema.ResourceData) *schema.ResourceData {
d.SetId(fabricPathEp.DistinguishedName)
d.Set("description", fabricPathEp.Description)

fabricPathEpMap, _ := fabricPathEp.ToMap()
d.Set("name", fabricPathEpMap["name"])

return d
}

func dataSourceAciFabricPathEndpointRead(d *schema.ResourceData, m interface{}) error {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
podID := d.Get("pod_id").(string)
nodeID := d.Get("node_id").(string)

pDN := fmt.Sprintf("topology/pod-%s/paths-%s", podID, nodeID)

rn := fmt.Sprintf("pathep-[%s]", name)

dn := fmt.Sprintf("%s/%s", pDN, rn)

fabricPathEp, err := getRemoteFabricPathEndpoint(aciClient, dn)
if err != nil {
return err
}

setFabricPathEndpointAttributes(fabricPathEp, d)
return nil
}
1 change: 1 addition & 0 deletions aci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func Provider() terraform.ResourceProvider {
"aci_spine_port_selector": dataSourceAciInterfaceProfile(),
"aci_spine_interface_profile": dataSourceAciSpineInterfaceProfile(),
"aci_spine_port_policy_group": dataSourceAciSpineAccessPortPolicyGroup(),
"aci_fabric_path_ep": dataSourceAciFabricPathEndpoint(),
},

ConfigureFunc: configureClient,
Expand Down
40 changes: 0 additions & 40 deletions aci/resource_aci_vzbrcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,6 @@ func resourceAciContract() *schema.Resource {
}
return false
},
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"d_to_port": &schema.Schema{
Expand All @@ -248,16 +238,6 @@ func resourceAciContract() *schema.Resource {
}
return false
},
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"ether_t": &schema.Schema{
Expand Down Expand Up @@ -387,16 +367,6 @@ func resourceAciContract() *schema.Resource {
}
return false
},
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"s_to_port": &schema.Schema{
Expand All @@ -422,16 +392,6 @@ func resourceAciContract() *schema.Resource {
}
return false
},
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"stateful": &schema.Schema{
Expand Down
40 changes: 0 additions & 40 deletions aci/resource_aci_vzentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,12 @@ func resourceAciFilterEntry() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"d_to_port": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"ether_t": &schema.Schema{
Expand Down Expand Up @@ -197,32 +177,12 @@ func resourceAciFilterEntry() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"s_to_port": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"unspecified",
"ftpData",
"smtp",
"dns",
"http",
"pop3",
"https",
"rtsp",
}, false),
},

"stateful": &schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-aci
go 1.12

require (
github.com/ciscoecosystem/aci-go-client v0.4.20
github.com/ciscoecosystem/aci-go-client v0.5.11
github.com/ghodss/yaml v1.0.0
github.com/hashicorp/terraform-plugin-sdk v1.14.0
github.com/hashicorp/terraform-plugin-test v1.4.3 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ github.com/ciscoecosystem/aci-go-client v0.5.7 h1:sXYYvpbvl7tTu8icpWYfq0A+Isnqmv
github.com/ciscoecosystem/aci-go-client v0.5.7/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v0.5.8 h1:ZpcqZBEiJJy6QEyAZeK1sdoBfG+W0OSwCyGAavHgA/4=
github.com/ciscoecosystem/aci-go-client v0.5.8/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v0.5.9 h1:aZoBr6wUFzbZJIfzrLE+VK7W6e3TsSI+PSxKe5UegCs=
github.com/ciscoecosystem/aci-go-client v0.5.9/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v0.5.10 h1:4WzzfnlQsMlbddxJJCuXFZxeWFSzNILF1ICBKv5MR/0=
github.com/ciscoecosystem/aci-go-client v0.5.10/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v0.5.11 h1:3Zoo+VRwzvkPuJDGdAAW5tT/wawgIzW+Vs4RGrXvx8Q=
github.com/ciscoecosystem/aci-go-client v0.5.11/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v1.0.0 h1:mTFw2AJBbUAVDd8OETQd0jD9EEJYv+a5bnXNskc46SY=
github.com/ciscoecosystem/aci-go-client v1.0.0/go.mod h1:jFrITzPN2qjycddQVHNFIDOe3rvR00YCdkPK7N24vkM=
github.com/ciscoecosystem/aci-go-client v1.0.1 h1:hemK22oIvaiA8KIpPp38z533qtlJvk0ujvCIagII+fs=
Expand Down Expand Up @@ -174,6 +180,8 @@ github.com/ciscoecosystem/aci-go-client v1.3.4-0.20200716070731-3c5343020306 h1:
github.com/ciscoecosystem/aci-go-client v1.3.4-0.20200716070731-3c5343020306/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v1.3.4 h1:+ZPRDoIxTsBBy+zWjcWKgNnXrNH9CgwKMZb84n9Rm1w=
github.com/ciscoecosystem/aci-go-client v1.3.4/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/ciscoecosystem/aci-go-client v1.3.8 h1:hqOgPGGzfjsXQHNueKXCQsmvrE/gUiWs9JAAbCHcayA=
github.com/ciscoecosystem/aci-go-client v1.3.8/go.mod h1:fhY7vWysK655g3Yp5Fz4Zje/JN4+moRe8RjwiRy0amQ=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
7 changes: 2 additions & 5 deletions vendor/github.com/ciscoecosystem/aci-go-client/client/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions vendor/github.com/ciscoecosystem/aci-go-client/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a5d784

Please sign in to comment.