Skip to content

Adding data sources for T0 & T1 gateway interfaces #1614

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

aruntony005
Copy link
Contributor

No description provided.

@aruntony005 aruntony005 changed the title Adding data source for T0 & T1 gateway interface [WIP] Adding data source for T0 & T1 gateway interface Apr 21, 2025
@tenthirtyam
Copy link
Contributor

Marking WIP as draft.

@tenthirtyam tenthirtyam marked this pull request as draft April 21, 2025 13:00
@aruntony005 aruntony005 force-pushed the gw-interfaces branch 4 times, most recently from af49c13 to 431a739 Compare April 28, 2025 14:42
@aruntony005 aruntony005 changed the title [WIP] Adding data source for T0 & T1 gateway interface Adding data sources for T0 & T1 gateway interfaces Apr 28, 2025
@aruntony005 aruntony005 marked this pull request as ready for review April 28, 2025 14:59
@aruntony005 aruntony005 requested review from ksamoray and annakhm April 28, 2025 15:00
@annakhm
Copy link
Contributor

annakhm commented Apr 28, 2025

Let's consider having a single data source nsxt_policy_gateway_interface, that would support both T0 and T1

aruntony005 added 14 commits May 5, 2025 17:02
Added a generic policy search function to get the gateway to which the interface is linked to and to get resources with multiple elements.
Fixed the Tier0 gateway id issue in the Tier0 interface data source by using the generic policy search function.

Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
Signed-off-by: Arun Tony <[email protected]>
…cceptance tests and documentation forthe data source

Signed-off-by: Arun Tony <[email protected]>
Optional: true,
Computed: false,
},
"segment_path": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should allow this to be an input - namely, pull the interface by gateway path and segment path.
The original PR also suggested to allow locale service as an input

Copy link
Member

Choose a reason for hiding this comment

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

@annakhm I think you meant that in the issue report the user would like to be able to search the interface by locale service too.

  1. I think we should use locale_service_path (ie: the parent_path) instead of local service name
  2. What about gateway_path? I think users should specify either service_path or gateway_path, but specifying both would probably not make sense.


* `id` - ID of the interface.
* `description` - The description of the resource.
* `edge_cluster_path` - The path of the Edge cluster where this gateway is placed. This attribute is not set for NSX Global Manager, where gateway can span across multiple sites. This attribute is set only for Tier0 gateways.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we only assigning this for T0 gateways?

}

if path != nil {
err := d.Set("path", *path)
Copy link
Contributor

@annakhm annakhm May 7, 2025

Choose a reason for hiding this comment

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

nil check is already included in d.Set, so its safe to go with d.Set("path", path). Same below

// },
Steps: []resource.TestStep{
{
Config: testAccNsxtPolicyTier0InterfaceDataSourceTemplate(t0InterfaceName, t1InterfaceName, t0GatewayName, t1GatewayName, transportZoneName, interfaceDescription),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to reuse the test for the resource interface that we already have. One option is to add the data source test to resource test, another option would be to reuse the terraform code that creates GW + segment + interface (testAccNsxtPolicyTier0InterfaceServiceTemplate), and create a separate data source on top of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants