Skip to content

Commit

Permalink
Merge pull request #462 from vmware/allow_vlan_ids_for_overlay
Browse files Browse the repository at this point in the history
Expose vlan_ids attribute for overlay segments
  • Loading branch information
annakhm authored Sep 15, 2020
2 parents a048372 + 0103907 commit dd6f54f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
5 changes: 1 addition & 4 deletions nsxt/resource_nsxt_policy_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
)

func resourceNsxtPolicySegment() *schema.Resource {
segSchema := getPolicyCommonSegmentSchema()
delete(segSchema, "vlan_ids")

return &schema.Resource{
Create: resourceNsxtPolicySegmentCreate,
Read: resourceNsxtPolicySegmentRead,
Expand All @@ -20,7 +17,7 @@ func resourceNsxtPolicySegment() *schema.Resource {
State: schema.ImportStatePassthrough,
},

Schema: segSchema,
Schema: getPolicyCommonSegmentSchema(false),
}
}

Expand Down
4 changes: 4 additions & 0 deletions nsxt/resource_nsxt_policy_segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestAccResourceNsxtPolicySegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "subnet.0.cidr", "12.12.2.1/24"),
resource.TestCheckResourceAttr(testResourceName, "domain_name", "tftest.org"),
resource.TestCheckResourceAttr(testResourceName, "overlay_id", "1011"),
resource.TestCheckResourceAttr(testResourceName, "vlan_ids.#", "2"),
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "OFF"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "true"),
Expand All @@ -161,6 +162,7 @@ func TestAccResourceNsxtPolicySegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "subnet.0.cidr", "12.12.2.1/24"),
resource.TestCheckResourceAttr(testResourceName, "domain_name", "tftest.org"),
resource.TestCheckResourceAttr(testResourceName, "overlay_id", "1011"),
resource.TestCheckResourceAttr(testResourceName, "vlan_ids.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "ON"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "false"),
Expand Down Expand Up @@ -524,6 +526,7 @@ resource "nsxt_policy_segment" "test" {
description = "Acceptance Test"
domain_name = "tftest.org"
overlay_id = 1011
vlan_ids = ["101", "102"]
transport_zone_path = data.nsxt_policy_transport_zone.test.path
Expand Down Expand Up @@ -552,6 +555,7 @@ resource "nsxt_policy_segment" "test" {
description = "Acceptance Test"
domain_name = "tftest.org"
overlay_id = 1011
vlan_ids = ["101-104"]
transport_zone_path = data.nsxt_policy_transport_zone.test.path
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_vlan_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func resourceNsxtPolicyVlanSegment() *schema.Resource {
segSchema := getPolicyCommonSegmentSchema()
segSchema := getPolicyCommonSegmentSchema(true)
delete(segSchema, "overlay_id")
delete(segSchema, "connectivity_path")

Expand Down
5 changes: 3 additions & 2 deletions nsxt/segment_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func getPolicySegmentSecurityProfilesSchema() *schema.Resource {
}
}

func getPolicyCommonSegmentSchema() map[string]*schema.Schema {
func getPolicyCommonSegmentSchema(vlanRequired bool) map[string]*schema.Schema {
return map[string]*schema.Schema{
"nsx_id": getNsxIDSchema(),
"path": getPathSchema(),
Expand Down Expand Up @@ -297,7 +297,8 @@ func getPolicyCommonSegmentSchema() map[string]*schema.Schema {
Type: schema.TypeString,
ValidateFunc: validateVLANIdOrRange,
},
Required: true,
Required: vlanRequired,
Optional: !vlanRequired,
},
"discovery_profile": {
Type: schema.TypeList,
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/policy_segment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The following arguments are supported:
* `connectivity_path` - (Optional) Policy path to the connecting Tier-0 or Tier-1.
* `domain_name`- (Optional) DNS domain names.
* `overlay_id` - (Optional) Overlay connectivity ID for this Segment.
* `vlan_ids` - (Optional) List of VLAN IDs or ranges. Specifying vlan ids can be useful for overlay segments, f.e. for EVPN.
* `transport_zone_path` - (Required) Policy path to the Overlay transport zone. This property is required if more than one overlay transport zone is defined, and none is marked as default.
* `dhcp_config_path` - (Optional) Policy path to DHCP server or relay configuration to use for subnets configured on this segment. This attribute is supported with NSX 3.0.0 onwards.
* `subnet` - (Optional) Subnet configuration block.
Expand Down

0 comments on commit dd6f54f

Please sign in to comment.