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

API Refactoring for VPN resources #866

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

2ez4szliu
Copy link
Contributor

NSX API that uses locale service path of VPN resources will be deprecated this PR adds support for the new API that uses gateway path.

Also change data_source_nsxt_policy_ipsec_vpn_local_endpoint to use regex-based search API.

Signed-off-by: Shizhao Liu lshizhao@vmware.com

@vmwclabot
Copy link
Member

@2ez4szliu, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

@vmwclabot vmwclabot added the dco-required DCO Required label Apr 5, 2023
@vmwclabot
Copy link
Member

@2ez4szliu, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

@vmwclabot vmwclabot removed the dco-required DCO Required label Apr 6, 2023
@2ez4szliu 2ez4szliu force-pushed the vpn-gateway-path branch 3 times, most recently from aca6719 to 2dc6a62 Compare April 8, 2023 21:34
localeServicePath := d.Get("locale_service_path").(string)
if gatewayPath == "" && localeServicePath == "" {
return fmt.Errorf("At least one of gateway path and locale service path should be provided for VPN resources")
}
isT0, gwID, localeServiceID, err := parseLocaleServicePolicyPath(localeServicePath)
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 block is repeated below, can we move it to a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

d.Set("locale_service_path", s[0])
} else {
d.Set("gateway_path", s[0])
}
return []*schema.ResourceData{d}, nil
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like new support is missing in deleteNsxtPolicyIPSecVpnService below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, seems it's also missing in getNsxtPolicyIPSecVpnService, now fixed

@2ez4szliu 2ez4szliu force-pushed the vpn-gateway-path branch 5 times, most recently from 977150a to 776658a Compare April 14, 2023 18:12
@annakhm
Copy link
Collaborator

annakhm commented Apr 14, 2023

/test-all

1 similar comment
@2ez4szliu
Copy link
Contributor Author

/test-all

@@ -142,7 +142,7 @@ func TestAccResourceNsxtPolicyL2VpnSession_tier1(t *testing.T) {
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason this test is only running for versions below 3.2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be "version higher than 3.2.0", now fixed

testResourceName := "nsxt_policy_ipsec_vpn_service.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOnlyLocalManager(t) },
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think version check is needed here, since GW api was not exposed for early versions (3.2.0?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, same change is made in l2_vpn_service_test

@@ -37,7 +37,8 @@ The following arguments are supported:
* `description` - (Optional) Description of the resource.
* `tag` - (Optional) A list of scope + tag pairs to associate with this resource.
* `nsx_id` - (Optional) The NSX ID of this resource. If set, this ID will be used to create the resource.
* `locale_service_path` - (Required) Path of the gateway locale service associated with the IPSec VPN Service.
* `locale_service_path` - (Optional) Path of the gateway locale service associated with the IPSec VPN Service.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should mark this as Deprecated (same for other resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -41,7 +43,8 @@ func resourceNsxtPolicyIPSecVpnService() *schema.Resource {
"description": getDescriptionSchema(),
"revision": getRevisionSchema(),
"tag": getTagsSchema(),
"locale_service_path": getPolicyPathSchema(true, false, "Polciy path for the locale service."),
"locale_service_path": getPolicyPathSchema(false, false, "Polciy path for the locale service."),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should mark this as Deprecated (same for other resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@2ez4szliu
Copy link
Contributor Author

/test-all

@2ez4szliu 2ez4szliu force-pushed the vpn-gateway-path branch 2 times, most recently from 0c507d7 to 8ead01c Compare April 19, 2023 05:12
@2ez4szliu
Copy link
Contributor Author

/test-all

Type: schema.TypeString,
Description: "Polciy path for the locale service.",
Optional: true,
ForceNew: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think ForceNew needs to be true here, since different API path would be used for updated locale service

Type: schema.TypeString,
Description: "Polciy path for the locale service.",
Optional: true,
ForceNew: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@annakhm
Copy link
Collaborator

annakhm commented Apr 20, 2023

LGTM, only small comment about ForceNew.
Is it possible to add a test that would move from locale_service_path to gateway_path?

NSX API that uses locale service path of VPN resources will be
deprecated, this PR adds support for the new API that uses gateway
path.

The change in this PR includes:
(1) Support for configuring VPN Resource with gateway path.
(2) change data_source_nsxt_policy_ipsec_vpn_local_endpoint to
use regex-based search API.
(3) For VPN Sessions, if only specify the direction of Tcp Mss
Clampling, the provider will use the auto-assigned value for
the Maximum Segment Size.

Signed-off-by: Shizhao Liu <lshizhao@vmware.com>
@2ez4szliu
Copy link
Contributor Author

LGTM, only small comment about ForceNew. Is it possible to add a test that would move from locale_service_path to gateway_path?

Added test case TestAccResourceNsxtPolicyIPSecVpnService_updateFromlocaleServicePathToGatewayPath and TestAccResourceNsxtPolicyL2VpnService_updateFromlocaleServicePathToGatewayPath

@2ez4szliu
Copy link
Contributor Author

/test-all

1 similar comment
@2ez4szliu
Copy link
Contributor Author

/test-all

@annakhm
Copy link
Collaborator

annakhm commented Apr 24, 2023

LGTM, only small comment about ForceNew. Is it possible to add a test that would move from locale_service_path to gateway_path?

Added test case TestAccResourceNsxtPolicyIPSecVpnService_updateFromlocaleServicePathToGatewayPath and TestAccResourceNsxtPolicyL2VpnService_updateFromlocaleServicePathToGatewayPath

Great, thanks!

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.

3 participants