Skip to content

Commit

Permalink
Merge pull request #627 from vmware/segment-urpf
Browse files Browse the repository at this point in the history
Support urpf_mode in segment advanced config
  • Loading branch information
annakhm authored May 27, 2021
2 parents 78a47a6 + 342c4b6 commit a8bc5f9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
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 @@ -151,6 +151,7 @@ func TestAccResourceNsxtPolicySegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "OFF"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "true"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.urpf_mode", "STRICT"),
),
},
{
Expand All @@ -167,6 +168,7 @@ func TestAccResourceNsxtPolicySegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "ON"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "false"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.urpf_mode", "NONE"),
),
},
},
Expand Down Expand Up @@ -588,6 +590,7 @@ resource "nsxt_policy_segment" "test" {
advanced_config {
connectivity = "OFF"
local_egress = true
urpf_mode = "STRICT"
}
}
`, name)
Expand Down Expand Up @@ -617,6 +620,7 @@ resource "nsxt_policy_segment" "test" {
advanced_config {
connectivity = "ON"
local_egress = false
urpf_mode = "NONE"
}
}
`, name)
Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_policy_vlan_segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestAccResourceNsxtPolicyVlanSegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "OFF"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "true"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.urpf_mode", "NONE"),
),
},
{
Expand All @@ -102,6 +103,7 @@ func TestAccResourceNsxtPolicyVlanSegment_updateAdvConfig(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.connectivity", "ON"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.local_egress", "false"),
resource.TestCheckResourceAttr(testResourceName, "advanced_config.0.urpf_mode", "STRICT"),
),
},
},
Expand Down Expand Up @@ -351,6 +353,7 @@ resource "nsxt_policy_vlan_segment" "test" {
advanced_config {
connectivity = "OFF"
local_egress = true
urpf_mode = "NONE"
}
}
`, name)
Expand Down
18 changes: 18 additions & 0 deletions nsxt/segment_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ var connectivityValues = []string{
model.SegmentAdvancedConfig_CONNECTIVITY_OFF,
}

var urpfModeValues = []string{
model.SegmentAdvancedConfig_URPF_MODE_NONE,
model.SegmentAdvancedConfig_URPF_MODE_STRICT,
}

func getPolicySegmentDhcpV4ConfigSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -182,6 +187,13 @@ func getPolicySegmentAdvancedConfigurationSchema() *schema.Resource {
Description: "The name of the switching uplink teaming policy for the bridge endpoint",
Optional: true,
},
"urpf_mode": {
Type: schema.TypeString,
Description: "This URPF mode is applied to the downlink logical router port created while attaching this segment to gateway",
Optional: true,
ValidateFunc: validation.StringInSlice(urpfModeValues, false),
Default: model.SegmentAdvancedConfig_URPF_MODE_STRICT,
},
},
}
}
Expand Down Expand Up @@ -744,6 +756,9 @@ func policySegmentResourceToInfraStruct(id string, d *schema.ResourceData, isVla
if teamingPolicy != "" {
advConfigStruct.UplinkTeamingPolicyName = &teamingPolicy
}

urpfMode := advConfigMap["urpf_mode"].(string)
advConfigStruct.UrpfMode = &urpfMode
}
obj.AdvancedConfig = &advConfigStruct
}
Expand Down Expand Up @@ -1292,6 +1307,9 @@ func nsxtPolicySegmentRead(d *schema.ResourceData, m interface{}, isVlan bool, i
if obj.AdvancedConfig.UplinkTeamingPolicyName != nil {
advConfig["uplink_teaming_policy"] = *obj.AdvancedConfig.UplinkTeamingPolicyName
}
if obj.AdvancedConfig.UrpfMode != nil {
advConfig["urpf_mode"] = *obj.AdvancedConfig.UrpfMode
}
// This is a list with 1 element
var advConfigList []map[string]interface{}
advConfigList = append(advConfigList, advConfig)
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/policy_fixed_segment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ The following arguments are supported:
* `hybrid` - (Optional) Boolean flag to identify a hybrid logical switch.
* `local_egress` - (Optional) Boolean flag to enable local egress when used in conjunction with L2VPN.
* `uplink_teaming_policy` - (Optional) The name of the switching uplink teaming policy for the bridge endpoint. This name corresponds to one of the switching uplink teaming policy names listed in the transport zone.
* `urpf_mode` - (Optional) URPF mode to be applied to gateway downlink interface. One of `STRICT`, `NONE`.

## Attributes Reference

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 @@ -96,6 +96,7 @@ The following arguments are supported:
* `hybrid` - (Optional) Boolean flag to identify a hybrid logical switch.
* `local_egress` - (Optional) Boolean flag to enable local egress when used in conjunction with L2VPN.
* `uplink_teaming_policy` - (Optional) The name of the switching uplink teaming policy for the bridge endpoint. This name corresponds to one of the switching uplink teaming policy names listed in the transport zone.
* `urpf_mode` - (Optional) URPF mode to be applied to gateway downlink interface. One of `STRICT`, `NONE`.
* `discovery_profile` - (Optional) IP and MAC discovery profile specification for the segment.
* `ip_discovery_profile_path` - (Optional) Path for IP discovery profile to be associated with the segment.
* `mac_discovery_profile_path` - (Optional) Path for MAC discovery profile to be associated with the segment.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/policy_vlan_segment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The following arguments are supported:
* `hybrid` - (Optional) Boolean flag to identify a hybrid logical switch.
* `local_egress` - (Optional) Boolean flag to enable local egress.
* `uplink_teaming_policy` - (Optional) The name of the switching uplink teaming policy for the bridge endpoint. This name corresponds to one of the switching uplink teaming policy names listed in the transport zone.
* `urpf_mode` - (Optional) URPF mode to be applied to gateway downlink interface. One of `STRICT`, `NONE`.
* `discovery_profile` - (Optional) IP and MAC discovery profile specification for the segment.
* `ip_discovery_profile_path` - (Optional) Path for IP discovery profile to be associated with the segment.
* `mac_discovery_profile_path` - (Optional) Path for MAC discovery profile to be associated with the segment.
Expand Down

0 comments on commit a8bc5f9

Please sign in to comment.