Skip to content

Commit

Permalink
feat: Adding Zside Port Service Token resource (#817)
Browse files Browse the repository at this point in the history
-Added Zside Port Service Token Resource Acc Tests
- Updated docs for Service Token Resource
  • Loading branch information
srushti-patl authored Nov 19, 2024
2 parents 2738579 + 540cc98 commit 242d3bf
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/resources/fabric_service_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ resource "equinix_fabric_service_token" "test" {
}
```

Zside Port Service Token
```terraform
resource "equinix_fabric_service_token" "test"{
type = "VC_TOKEN"
description = "Zside COLO Service Token"
expiration_date_time = "2025-01-18T06:43:49.981Z"
service_token_connection {
type = "EVPL_VC"
supported_bandwidths = [50, 200, 10000]
z_side {
access_point_selectors{
type = "COLO"
port {
uuid = "<port_uuid>"
}
link_protocol {
type = "DOT1Q"
vlan_tag = "2087"
}
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]", "[email protected]"]
}
}
```

Zside Virtual Device Service Token
```terraform
resource "equinix_fabric_service_token" "test" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "equinix_fabric_service_token" "test"{
type = "VC_TOKEN"
description = "Zside COLO Service Token"
expiration_date_time = "2025-01-18T06:43:49.981Z"
service_token_connection {
type = "EVPL_VC"
supported_bandwidths = [50, 200, 10000]
z_side {
access_point_selectors{
type = "COLO"
port {
uuid = "<port_uuid>"
}
link_protocol {
type = "DOT1Q"
vlan_tag = "2087"
}
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]", "[email protected]"]
}
}
79 changes: 79 additions & 0 deletions internal/resources/fabric/service_token/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,53 @@ func TestAccFabricAsidePortServiceToken_PNFV(t *testing.T) {
})
}

func TestAccFabricZsidePortServiceToken_PNFV(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
var portUuid string
if len(ports) > 0 {
portUuid = ports["pnfv"]["dot1q"][0].GetUuid()
}
serviceTokenName, serviceTokenUpdatedName := "token_zport_PNFV", "UP_Token_zport_PNFV"
serviceTokenDescription, serviceTokenUpdatedDescription := "zside port token", "Updated zside port token"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t) },
Providers: acceptance.TestAccProviders,
CheckDestroy: CheckServiceTokenDelete,
Steps: []resource.TestStep{
{
Config: testAccFabricZsidePortServiceTokenConfig(serviceTokenName, serviceTokenDescription, portUuid),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("equinix_fabric_service_token.test", "uuid"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "name", serviceTokenName),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "type", "VC_TOKEN"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "description", serviceTokenDescription),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "expiration_date_time", "2025-01-18T06:43:49.981Z"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.supported_bandwidths.#", "3"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.port.0.uuid", portUuid),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.link_protocol.0.type", "DOT1Q"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.link_protocol.0.vlan_tag", "2087"),
),
ExpectNonEmptyPlan: false,
},
{
Config: testAccFabricZsidePortServiceTokenConfig(serviceTokenUpdatedName, serviceTokenUpdatedDescription, portUuid),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("equinix_fabric_service_token.test", "uuid"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "name", serviceTokenUpdatedName),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "type", "VC_TOKEN"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "description", serviceTokenUpdatedDescription),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "expiration_date_time", "2025-01-18T06:43:49.981Z"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.supported_bandwidths.#", "3"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.port.0.uuid", portUuid),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.link_protocol.0.type", "DOT1Q"),
resource.TestCheckResourceAttr("equinix_fabric_service_token.test", "service_token_connection.0.z_side.0.access_point_selectors.0.link_protocol.0.vlan_tag", "2087"),
),
ExpectNonEmptyPlan: false,
},
},
})
}

func testAccFabricZsideVirtualDeviceServiceTokenConfig(serviceTokenName string, serviceTokenDescription string, virtualDeviceUuid string) string {
return fmt.Sprintf(
`resource "equinix_fabric_service_token" "test"{
Expand Down Expand Up @@ -174,6 +221,38 @@ func testAccFabricAsidePortServiceTokenConfig(serviceTokenName string, serviceTo
`, serviceTokenName, serviceTokenDescription, portUuid)
}

func testAccFabricZsidePortServiceTokenConfig(serviceTokenName string, serviceTokenDescription string, portUuid string) string {
return fmt.Sprintf(
`resource "equinix_fabric_service_token" "test"{
type = "VC_TOKEN"
name = "%s"
description = "%s"
expiration_date_time = "2025-01-18T06:43:49.981Z"
service_token_connection {
type = "EVPL_VC"
supported_bandwidths = [50, 200, 10000]
z_side {
access_point_selectors{
type = "COLO"
port {
uuid = "%s"
}
link_protocol {
type = "DOT1Q"
vlan_tag = "2087"
}
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]", "[email protected]"]
}
}
`, serviceTokenName, serviceTokenDescription, portUuid)
}

func CheckServiceTokenDelete(s *terraform.State) error {
ctx := context.Background()
for _, rs := range s.RootModule().Resources {
Expand Down
3 changes: 3 additions & 0 deletions templates/resources/fabric_service_token.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Additional documentation:
Aside Port Service Token
{{tffile "examples/resources/equinix_fabric_service_token/aside_colo_service_token.tf"}}

Zside Port Service Token
{{tffile "examples/resources/equinix_fabric_service_token/zside_colo_service_token.tf"}}

Zside Virtual Device Service Token
{{tffile "examples/resources/equinix_fabric_service_token/zside_vd_service_token.tf"}}

Expand Down

0 comments on commit 242d3bf

Please sign in to comment.