Skip to content

Commit 982fdde

Browse files
camschaeciscocamschaeaitestino
authored
[TRM] Implement VRF VNID/EVPN-Instance Support in Terraform Provider (#389)
* Add VRF VNID and EVPN-Instance support - Add vnid configuration support to iosxe_vrf resource - Support VNID-only mode for automatic route-target generation - Support VNID with explicit VNI configuration - Support optional core-vlan parameter (platform-dependent) - Tested on Cat8k routers (17.12, 17.15) and Cat9k switches - Router platforms: VNID with/without explicit VNI (no core-vlan) - Switch platforms: VNID with/without explicit VNI+core-vlan * Fix schema validation error: remove max_elements from VNID definition - Removed max_elements field which is not supported by schema - Regenerated all provider code with corrected definition * fix: Revert template to PATCH-first and exclude prerequisite-dependent VRF attributes from tests - Revert gen/templates/resource.go to upstream PATCH-first logic for Create (PUT-only was not required for VRF VNID feature) - Add exclude_test to core_vlan (switch-only attribute, not supported on routers) - Add exclude_test to MDT attributes that require multicast/BGP/VXLAN prerequisites: - ipv4_mdt_default_address - ipv4_mdt_auto_discovery_vxlan - ipv4_mdt_auto_discovery_vxlan_inter_as - ipv4_mdt_overlay_use_bgp - ipv4_mdt_overlay_use_bgp_spt_only - ipv4_mdt_data_multicast - ipv4_mdt_data_threshold The original test failures were caused by MDT attributes requiring prerequisites not present in the test environment, not by PATCH vs PUT logic. * feat(vrf): rename evpn_instance_vni_vni_num to evpn_instance_vni and use PATCH for Create - Renamed tf_name from evpn_instance_vni_vni_num to evpn_instance_vni for cleaner API - Updated template to use PATCH with fallback to PUT for resource creation - Added exclude_test for core_vlan and MDT attributes (platform-specific) - Regenerated provider code and documentation --------- Co-authored-by: Cameron Schaeffer <[email protected]> Co-authored-by: Andrea Testino <[email protected]>
1 parent d89ca02 commit 982fdde

File tree

9 files changed

+584
-82
lines changed

9 files changed

+584
-82
lines changed

docs/data-sources/vrf.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ data "iosxe_vrf" "example" {
6969
- `rd_auto` (Boolean) Specify to enable auto Route Distinguisher
7070
- `route_target_export` (Attributes Set) Export Target-VPN community (see [below for nested schema](#nestedatt--route_target_export))
7171
- `route_target_import` (Attributes Set) Import Target-VPN community (see [below for nested schema](#nestedatt--route_target_import))
72+
- `vnid` (Attributes List) Specify VNID for route-target auto generation (see [below for nested schema](#nestedatt--vnid))
7273
- `vpn_id` (String) Configure VPN ID in rfc2685 format
7374

7475
<a id="nestedatt--ipv4_mdt_data_multicast"></a>
@@ -175,3 +176,20 @@ Read-Only:
175176

176177
- `stitching` (Boolean) VXLAN route target set
177178
- `value` (String) Value
179+
180+
181+
<a id="nestedatt--vnid"></a>
182+
### Nested Schema for `vnid`
183+
184+
Read-Only:
185+
186+
- `evpn_instance_vni` (Attributes List) Specify explicit NVE L3 VNI number (see [below for nested schema](#nestedatt--vnid--evpn_instance_vni))
187+
- `vnid_value` (Number) VNID value for route-target auto generation
188+
189+
<a id="nestedatt--vnid--evpn_instance_vni"></a>
190+
### Nested Schema for `vnid.evpn_instance_vni`
191+
192+
Read-Only:
193+
194+
- `core_vlan` (Number) Core vlan number to associate with VNI (explicit VNI mode)
195+
- `vni_num` (Number) The NVE L3 VNI number

docs/resources/vrf.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,18 @@ resource "iosxe_vrf" "example" {
6969
value = "22:22"
7070
}
7171
]
72-
ipv6_import_map = "IMPORT-MAP-1"
73-
ipv6_export_map = "EXPORT-MAP-1"
74-
ipv4_mdt_default_address = "239.1.1.1"
75-
ipv4_mdt_data_multicast = [
72+
ipv6_import_map = "IMPORT-MAP-1"
73+
ipv6_export_map = "EXPORT-MAP-1"
74+
vnid = [
7675
{
77-
address = "239.1.2.0"
78-
wildcard = "0.0.0.255"
76+
vnid_value = 10001
77+
evpn_instance_vni = [
78+
{
79+
vni_num = 20000
80+
}
81+
]
7982
}
8083
]
81-
ipv4_mdt_data_threshold = 50
8284
}
8385
```
8486

@@ -132,6 +134,7 @@ resource "iosxe_vrf" "example" {
132134
- `rd_auto` (Boolean) Specify to enable auto Route Distinguisher
133135
- `route_target_export` (Attributes Set) Export Target-VPN community (see [below for nested schema](#nestedatt--route_target_export))
134136
- `route_target_import` (Attributes Set) Import Target-VPN community (see [below for nested schema](#nestedatt--route_target_import))
137+
- `vnid` (Attributes List) Specify VNID for route-target auto generation (see [below for nested schema](#nestedatt--vnid))
135138
- `vpn_id` (String) Configure VPN ID in rfc2685 format
136139

137140
### Read-Only
@@ -271,6 +274,32 @@ Optional:
271274

272275
- `stitching` (Boolean) VXLAN route target set
273276

277+
278+
<a id="nestedatt--vnid"></a>
279+
### Nested Schema for `vnid`
280+
281+
Required:
282+
283+
- `vnid_value` (Number) VNID value for route-target auto generation
284+
- Range: `1`-`2147483647`
285+
286+
Optional:
287+
288+
- `evpn_instance_vni` (Attributes List) Specify explicit NVE L3 VNI number (see [below for nested schema](#nestedatt--vnid--evpn_instance_vni))
289+
290+
<a id="nestedatt--vnid--evpn_instance_vni"></a>
291+
### Nested Schema for `vnid.evpn_instance_vni`
292+
293+
Required:
294+
295+
- `vni_num` (Number) The NVE L3 VNI number
296+
- Range: `4096`-`16777215`
297+
298+
Optional:
299+
300+
- `core_vlan` (Number) Core vlan number to associate with VNI (explicit VNI mode)
301+
- Range: `1`-`4094`
302+
274303
## Import
275304

276305
Import is supported using the following syntax:

examples/resources/iosxe_vrf/resource.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ resource "iosxe_vrf" "example" {
5454
value = "22:22"
5555
}
5656
]
57-
ipv6_import_map = "IMPORT-MAP-1"
58-
ipv6_export_map = "EXPORT-MAP-1"
59-
ipv4_mdt_default_address = "239.1.1.1"
60-
ipv4_mdt_data_multicast = [
57+
ipv6_import_map = "IMPORT-MAP-1"
58+
ipv6_export_map = "EXPORT-MAP-1"
59+
vnid = [
6160
{
62-
address = "239.1.2.0"
63-
wildcard = "0.0.0.255"
61+
vnid_value = 10001
62+
evpn_instance_vni = [
63+
{
64+
vni_num = 20000
65+
}
66+
]
6467
}
6568
]
66-
ipv4_mdt_data_threshold = 50
6769
}

gen/definitions/vrf.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,51 @@ attributes:
160160
tf_name: ipv6_export_map
161161
description: Route-map based VRF export for IPv6
162162
example: EXPORT-MAP-1
163+
- yang_name: vnid
164+
tf_name: vnid
165+
type: List
166+
attributes:
167+
- yang_name: vnid-value
168+
tf_name: vnid_value
169+
type: Int64
170+
id: true
171+
description: VNID value for route-target auto generation
172+
example: 10001
173+
- yang_name: evpn-instance/vni/vni-auto-num/vni-num/vni-num
174+
xpath: evpn-instance/vni/vni-num
175+
tf_name: evpn_instance_vni
176+
type: List
177+
description: Specify explicit NVE L3 VNI number
178+
attributes:
179+
- yang_name: vni-num
180+
tf_name: vni_num
181+
type: Int64
182+
id: true
183+
description: The NVE L3 VNI number
184+
example: 20000
185+
- yang_name: core-vlan
186+
tf_name: core_vlan
187+
type: Int64
188+
description: Core vlan number to associate with VNI (explicit VNI mode)
189+
exclude_test: true
190+
example: 200
163191
- yang_name: address-family/ipv4/mdt/default/address
164192
tf_name: ipv4_mdt_default_address
165193
description: MDT default group IPv4 address
194+
exclude_test: true
166195
example: 239.1.1.1
167196
- yang_name: address-family/ipv4/mdt/auto-discovery/auto-discovery/vxlan/vxlan-config/vxlan
168197
xpath: address-family/ipv4/mdt/auto-discovery/vxlan-config/vxlan
169198
tf_name: ipv4_mdt_auto_discovery_vxlan
170199
description: Enable BGP auto-discovery for VxLAN
200+
exclude_test: true
171201
example: true
172202
test_tags: [C9000V]
173203
- yang_name: address-family/ipv4/mdt/auto-discovery/auto-discovery/vxlan/vxlan-config/inter-as
174204
xpath: address-family/ipv4/mdt/auto-discovery/vxlan-config/inter-as
175205
tf_name: ipv4_mdt_auto_discovery_vxlan_inter_as
176206
description: Enable Inter-AS BGP auto-discovery for VxLAN
207+
exclude_test: true
177208
example: true
178209
test_tags: [C9000V]
179210
- yang_name: address-family/ipv4/mdt/auto-discovery/auto-discovery/interworking/interworking/interworking/vxlan-pim/vxlan-pim-config/vxlan-pim
@@ -191,16 +222,19 @@ attributes:
191222
- yang_name: address-family/ipv4/mdt/overlay/use-bgp-config
192223
tf_name: ipv4_mdt_overlay_use_bgp
193224
description: Enable BGP for MDT overlay signaling
225+
exclude_test: true
194226
example: true
195227
test_tags: [C9000V]
196228
- yang_name: address-family/ipv4/mdt/overlay/use-bgp-config/spt-only
197229
tf_name: ipv4_mdt_overlay_use_bgp_spt_only
198230
description: Enable Shortest path tree-only ASM mode
231+
exclude_test: true
199232
example: true
200233
test_tags: [C9000V]
201234
- yang_name: address-family/ipv4/mdt/data/multicast
202235
tf_name: ipv4_mdt_data_multicast
203236
type: List
237+
exclude_test: true
204238
description: MDT data multicast group ranges
205239
attributes:
206240
- yang_name: address
@@ -218,6 +252,7 @@ attributes:
218252
- yang_name: address-family/ipv4/mdt/data/threshold
219253
tf_name: ipv4_mdt_data_threshold
220254
description: MDT switching threshold in Kbps (1-4294967)
255+
exclude_test: true
221256
example: 50
222257
- yang_name: address-family/ipv4/evpn-mcast/mdt-def-addr
223258
tf_name: ipv4_evpn_mcast_mdt_default_address

internal/provider/data_source_iosxe_vrf.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/provider/data_source_iosxe_vrf_test.go

Lines changed: 7 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)