From 3425c54fbd85ddc66640efbd6cf08c589a63611f Mon Sep 17 00:00:00 2001 From: graysonwu Date: Mon, 31 Jul 2023 12:29:42 -0700 Subject: [PATCH] Address comments Signed-off-by: graysonwu --- nsxt/resource_nsxt_policy_vni_pool.go | 4 +- nsxt/resource_nsxt_policy_vni_pool_test.go | 12 +++- website/docs/d/policy_vni_pool.html.markdown | 2 +- website/docs/r/policy_vni_pool.html.markdown | 67 ++++++++++++++++++++ 4 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 website/docs/r/policy_vni_pool.html.markdown diff --git a/nsxt/resource_nsxt_policy_vni_pool.go b/nsxt/resource_nsxt_policy_vni_pool.go index ae3388f67..eafa4c2b8 100644 --- a/nsxt/resource_nsxt_policy_vni_pool.go +++ b/nsxt/resource_nsxt_policy_vni_pool.go @@ -1,4 +1,4 @@ -/* Copyright © 2019 VMware, Inc. All Rights Reserved. +/* Copyright © 2023 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: MPL-2.0 */ package nsxt @@ -21,7 +21,7 @@ func resourceNsxtPolicyVniPool() *schema.Resource { Update: resourceNsxtPolicyVniPoolUpdate, Delete: resourceNsxtPolicyVniPoolDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: nsxtPolicyPathResourceImporter, }, Schema: map[string]*schema.Schema{ diff --git a/nsxt/resource_nsxt_policy_vni_pool_test.go b/nsxt/resource_nsxt_policy_vni_pool_test.go index 8b24e09ab..5898dcc9f 100644 --- a/nsxt/resource_nsxt_policy_vni_pool_test.go +++ b/nsxt/resource_nsxt_policy_vni_pool_test.go @@ -1,4 +1,4 @@ -/* Copyright © 2020 VMware, Inc. All Rights Reserved. +/* Copyright © 2023 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: MPL-2.0 */ package nsxt @@ -29,7 +29,10 @@ func TestAccResourceNsxtPolicyVniPool_basic(t *testing.T) { testResourceName := "nsxt_policy_vni_pool.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccOnlyLocalManager(t) + testAccPreCheck(t) + }, Providers: testAccProviders, CheckDestroy: func(state *terraform.State) error { return testAccNsxtPolicyVniPoolCheckDestroy(state, accTestPolicyVniPoolUpdateAttributes["display_name"]) @@ -73,7 +76,10 @@ func TestAccResourceNsxtPolicyVniPool_importBasic(t *testing.T) { testResourceName := "nsxt_policy_vni_pool.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccOnlyLocalManager(t) + testAccPreCheck(t) + }, Providers: testAccProviders, CheckDestroy: func(state *terraform.State) error { return testAccNsxtPolicyVniPoolCheckDestroy(state, accTestPolicyVniPoolUpdateAttributes["display_name"]) diff --git a/website/docs/d/policy_vni_pool.html.markdown b/website/docs/d/policy_vni_pool.html.markdown index a33a7aeff..16a99070c 100644 --- a/website/docs/d/policy_vni_pool.html.markdown +++ b/website/docs/d/policy_vni_pool.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Segments" +subcategory: "EVPN" layout: "nsxt" page_title: "NSXT: policy_vni_pool" description: Policy VNI Pool Config data source. diff --git a/website/docs/r/policy_vni_pool.html.markdown b/website/docs/r/policy_vni_pool.html.markdown new file mode 100644 index 000000000..fc50b95e0 --- /dev/null +++ b/website/docs/r/policy_vni_pool.html.markdown @@ -0,0 +1,67 @@ +--- +subcategory: "EVPN" +layout: "nsxt" +page_title: "NSXT: nsxt_policy_vni_pool" +description: A resource to configure VNI Pool on NSX Policy manager. +--- + +# nsxt_policy_vni_pool + +This resource provides a method for the management of VNI Pools. + +This resource is applicable to NSX Policy Manager. + +This resource is supported with NSX 3.0.0 onwards. + +## Example Usage + +```hcl +resource "nsxt_policy_vni_pool" "test_vni_pool" { + description = "vnipool1" + display_name = "terraform provisioned VNI pool" + + start = 80000 + end = 90000 + + tag { + scope = "color" + tag = "red" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `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. +* `nsx_id` - (Optional) The NSX ID of this resource. If set, this ID will be used to create the policy resource. +* `start` - (Required) Start value of VNI Pool range. Minimum: 75001, Maximum: 16777215. +* `end` - (Required) End value of VNI Pool range. Minimum: 75001, Maximum: 16777215. + +## Attributes Reference + +In addition to arguments listed above, the following attributes are exported: + +* `revision` - Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging. +* `path` - The NSX path of the policy resource. + +## Importing + +An existing VNI Pool can be [imported][docs-import] into this resource, via the following command: + +[docs-import]: https://www.terraform.io/cli/import + +``` +terraform import nsxt_policy_vni_pool.vnipool1 ID +``` + +The above command imports the VNI Pool named `vnipool1` with the NSX Policy ID `ID`. + +``` +terraform import nsxt_policy_vni_pool.vnipool1 POLICY_PATH +``` +The above command imports the VNI pool named `vnipool1` with the policy path `POLICY_PATH`. +Note: for multitenancy projects only the later form is usable. \ No newline at end of file