Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding Zside Port Service Token resource #817

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
srushti-patl marked this conversation as resolved.
Show resolved Hide resolved
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're adding tests for Zside, but then have documentation related to Aside. I'm confused how this is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the wrong name in the documentation. It's zside service token example. Apologize for the confusion.

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
Loading