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

GRE tunnel resource implementation #1091

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Conversation

ksamoray
Copy link
Collaborator

@ksamoray ksamoray commented Jan 28, 2024

Fixes: #1027

@ksamoray ksamoray force-pushed the gre_tunnel branch 2 times, most recently from 3fb65c8 to 4e33da5 Compare January 28, 2024 13:21
@ksamoray
Copy link
Collaborator Author

/test-all

Type: schema.TypeString,
Description: "Destination IPv4 address",
Required: true,
ValidateFunc: validateSingleIP(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is IPv4 only, there is validation.IsIPv4Address helper. Not sure the description is accurate though

"locale_service_path": {
Type: schema.TypeString,
Description: "Policy path of associated Gateway Locale Service on NSX",
Required: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

ForceNew?

urpf_mode = "STRICT"


tag {
Copy link
Collaborator

Choose a reason for hiding this comment

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

since this is a resource for dependency, I think we should provide minimal working config (tags etc. not needed)

testResourceName := "nsxt_policy_tier0_gateway_gre_tunnel.test"
name := getAccTestResourceName()

resource.Test(t, resource.TestCase{
Copy link
Collaborator

Choose a reason for hiding this comment

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

good call for not making this one Parallel :)

@ksamoray
Copy link
Collaborator Author

/test-all

@salv-orlando salv-orlando added this to the v3.5.0 milestone Feb 5, 2024

# nsxt_policy_tier0_gateway_gre_tunnel

This resource provides a method for the management of a Tier-0 gateway GRE tunnel. Note that edge cluster and in interface must be configured on Tier-0 Gateway in order to configure GRE tunnels on it.
Copy link
Member

Choose a reason for hiding this comment

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

User-level comment: What's the "in" interface? It's not a term I'm familiar with for Tier-0 gateways

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be "an interface" :)

}

resource "nsxt_policy_tier0_gateway" "test" {
display_name = "terraform-acctest-resource-74743"
Copy link
Member

Choose a reason for hiding this comment

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

pedant nit: For documentation I would use simple names. I think you might have extracted those from an acceptance test run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly... Will replace the name.


* `display_name` - (Required) Display name of the resource.
* `description` - (Optional) Description of the resource.
* `tag` - (Optional) A list of scope + tag pairs to associate with this resource.
Copy link
Member

Choose a reason for hiding this comment

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

Is this "tags" (plural)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's always tag in all our resources.
And as a general rule - we use singular naming for complex objects as they appear in HCL as a sequence of individual objects, e.g here or here with rule.
For list of simple types (e.g string) we use plural naming, e.g here with ip_addresses.


obj, err := tier0GatewayGRETunnelFromSchema(d)
if err != nil {
return fmt.Errorf("failed to create GRE Tunnel: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

nit abou the error message: we have not yet tried the creation here, so maybe the error should state "unable to create the GRE tunnel" or something like that

@ksamoray
Copy link
Collaborator Author

ksamoray commented Feb 6, 2024

/test-all

}
data "nsxt_policy_gateway_locale_service" "test" {
gateway_path = nsxt_policy_tier0_gateway.test.path
depends_on = [data.nsxt_policy_realization_info.realization_info]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the config fail without this? Policy intent should not depend on realization state..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IDK - tests pass without it. But would I be able to retrieve locale id while related stuff isn't realized?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see why not.. everything is on policy level

@ksamoray
Copy link
Collaborator Author

ksamoray commented Feb 7, 2024

/test-all

enable_pim = "true"
}

data "nsxt_policy_realization_info" "realization_info" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not needed anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, it's useless.

@ksamoray
Copy link
Collaborator Author

ksamoray commented Feb 8, 2024

/test-all

@ksamoray ksamoray merged commit 691b55b into vmware:master Feb 8, 2024
7 checks passed
@ksamoray ksamoray deleted the gre_tunnel branch February 8, 2024 19:41
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.

Support GRE tunnels for Tier-0
3 participants