Skip to content

Commit a24692e

Browse files
authored
Resolve Issue #475 (#476)
1 parent 095c4c1 commit a24692e

12 files changed

+417
-119
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add `sdwan_policy_group` resource and data source
99
- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source
1010
- Add `gateway` attribute for `ipv4_static_routes` and `ipv6_static_routes` in `sdwan_service_lan_vpn_feature` resource
11+
- Fix issue causing `sdwan_transport_routing_bgp_feature` to fail to apply when `policy_type` is set to `off`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/475)
1112

1213
## 0.6.2
1314

docs/data-sources/service_routing_bgp_feature.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,24 @@ Read-Only:
142142

143143
Read-Only:
144144

145+
- `disable_peer_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer
146+
- `disable_peer_max_number_of_prefixes_variable` (String) Variable name
147+
- `disable_peer_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message
148+
- `disable_peer_threshold_variable` (String) Variable name
145149
- `family_type` (String) Set IPv4 unicast address family
146150
- `in_route_policy_id` (String)
147-
- `max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer
148-
- `max_number_of_prefixes_variable` (String) Variable name
149151
- `out_route_policy_id` (String)
150152
- `policy_type` (String) Neighbor received maximum prefix policy is disabled.
151153
- `restart_interval` (Number) Set the restart interval(minutes) when to restart BGP connection if threshold is exceeded
152154
- `restart_interval_variable` (String) Variable name
153-
- `threshold` (Number) Set threshold(1 to 100) at which to generate a warning message
154-
- `threshold_variable` (String) Variable name
155+
- `restart_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer
156+
- `restart_max_number_of_prefixes_variable` (String) Variable name
157+
- `restart_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message
158+
- `restart_threshold_variable` (String) Variable name
159+
- `warning_message_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer
160+
- `warning_message_max_number_of_prefixes_variable` (String) Variable name
161+
- `warning_message_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message
162+
- `warning_message_threshold_variable` (String) Variable name
155163

156164

157165

docs/guides/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ description: |-
1717
- Add `sdwan_policy_group` resource and data source
1818
- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source
1919
- Add `gateway` attribute for `ipv4_static_routes` and `ipv6_static_routes` in `sdwan_service_lan_vpn_feature` resource
20+
- Fix issue causing `sdwan_transport_routing_bgp_feature` to fail to apply when `policy_type` is set to `off`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/475)
2021

2122
## 0.6.2
2223

docs/resources/service_routing_bgp_feature.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ resource "sdwan_service_routing_bgp_feature" "example" {
5353
allowas_in_number = 1
5454
address_families = [
5555
{
56-
family_type = "ipv4-unicast"
57-
max_number_of_prefixes = 2000
58-
threshold = 75
59-
policy_type = "restart"
60-
restart_interval = 30
56+
family_type = "ipv4-unicast"
57+
policy_type = "restart"
58+
restart_max_number_of_prefixes = 2000
59+
restart_threshold = 75
60+
restart_interval = 30
6161
}
6262
]
6363
}
@@ -289,20 +289,35 @@ Optional:
289289

290290
Optional:
291291

292+
- `disable_peer_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer, Attribute conditional on `policy_type` being equal to `disable-peer`
293+
- Range: `1`-`4294967295`
294+
- `disable_peer_max_number_of_prefixes_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `disable-peer`
295+
- `disable_peer_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message, Attribute conditional on `policy_type` being equal to `disable-peer`
296+
- Range: `1`-`100`
297+
- Default value: `75`
298+
- `disable_peer_threshold_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `disable-peer`
292299
- `family_type` (String) Set IPv4 unicast address family
293300
- `in_route_policy_id` (String)
294-
- `max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer
295-
- Range: `1`-`4294967295`
296-
- `max_number_of_prefixes_variable` (String) Variable name
297301
- `out_route_policy_id` (String)
298302
- `policy_type` (String) Neighbor received maximum prefix policy is disabled.
299-
- `restart_interval` (Number) Set the restart interval(minutes) when to restart BGP connection if threshold is exceeded
303+
- Choices: `restart`, `off`, `warning-only`, `disable-peer`
304+
- `restart_interval` (Number) Set the restart interval(minutes) when to restart BGP connection if threshold is exceeded, Attribute conditional on `policy_type` being equal to `restart`
300305
- Range: `1`-`65535`
301-
- `restart_interval_variable` (String) Variable name
302-
- `threshold` (Number) Set threshold(1 to 100) at which to generate a warning message
306+
- `restart_interval_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `restart`
307+
- `restart_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer, Attribute conditional on `policy_type` being equal to `restart`
308+
- Range: `1`-`4294967295`
309+
- `restart_max_number_of_prefixes_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `restart`
310+
- `restart_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message, Attribute conditional on `policy_type` being equal to `restart`
303311
- Range: `1`-`100`
304312
- Default value: `75`
305-
- `threshold_variable` (String) Variable name
313+
- `restart_threshold_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `restart`
314+
- `warning_message_max_number_of_prefixes` (Number) Set maximum number of prefixes accepted from BGP peer, Attribute conditional on `policy_type` being equal to `warning-only`
315+
- Range: `1`-`4294967295`
316+
- `warning_message_max_number_of_prefixes_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `warning-only`
317+
- `warning_message_threshold` (Number) Set threshold(1 to 100) at which to generate a warning message, Attribute conditional on `policy_type` being equal to `warning-only`
318+
- Range: `1`-`100`
319+
- Default value: `75`
320+
- `warning_message_threshold_variable` (String) Variable name, Attribute conditional on `policy_type` being equal to `warning-only`
306321

307322

308323

examples/resources/sdwan_service_routing_bgp_feature/resource.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ resource "sdwan_service_routing_bgp_feature" "example" {
3636
allowas_in_number = 1
3737
address_families = [
3838
{
39-
family_type = "ipv4-unicast"
40-
max_number_of_prefixes = 2000
41-
threshold = 75
42-
policy_type = "restart"
43-
restart_interval = 30
39+
family_type = "ipv4-unicast"
40+
policy_type = "restart"
41+
restart_max_number_of_prefixes = 2000
42+
restart_threshold = 75
43+
restart_interval = 30
4444
}
4545
]
4646
}

gen/definitions/profile_parcels/service_routing_bgp.yaml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,69 @@ attributes:
101101
- model_name: familyType
102102
id: true
103103
example: ipv4-unicast
104+
- model_name: policyType
105+
data_path: [maxPrefixConfig]
106+
type: String
107+
enum_values: ['restart', 'off', 'warning-only', 'disable-peer']
108+
example: restart
104109
- model_name: prefixNum
105-
tf_name: max_number_of_prefixes
110+
tf_name: restart_max_number_of_prefixes
106111
data_path: [maxPrefixConfig]
107112
example: 2000
113+
conditional_attribute:
114+
name: policyType
115+
value: restart
108116
- model_name: threshold
117+
tf_name: restart_threshold
109118
data_path: [maxPrefixConfig]
110119
default_value: 75
111120
default_value_present: true
112121
example: 75
113-
- model_name: policyType
114-
data_path: [maxPrefixConfig]
115-
type: String
116-
example: restart
122+
conditional_attribute:
123+
name: policyType
124+
value: restart
117125
- model_name: restartInterval
118126
data_path: [maxPrefixConfig]
119127
example: 30
128+
conditional_attribute:
129+
name: policyType
130+
value: restart
131+
- model_name: prefixNum
132+
tf_name: warning_message_max_number_of_prefixes
133+
data_path: [maxPrefixConfig]
134+
example: 2000
135+
exclude_test: true
136+
conditional_attribute:
137+
name: policyType
138+
value: warning-only
139+
- model_name: threshold
140+
tf_name: warning_message_threshold
141+
data_path: [maxPrefixConfig]
142+
default_value: 75
143+
default_value_present: true
144+
example: 75
145+
exclude_test: true
146+
conditional_attribute:
147+
name: policyType
148+
value: warning-only
149+
- model_name: prefixNum
150+
tf_name: disable_peer_max_number_of_prefixes
151+
data_path: [maxPrefixConfig]
152+
example: 2000
153+
exclude_test: true
154+
conditional_attribute:
155+
name: policyType
156+
value: disable-peer
157+
- model_name: threshold
158+
tf_name: disable_peer_threshold
159+
data_path: [maxPrefixConfig]
160+
default_value: 75
161+
default_value_present: true
162+
example: 75
163+
exclude_test: true
164+
conditional_attribute:
165+
name: policyType
166+
value: disable-peer
120167
- model_name: refId
121168
tf_name: in_route_policy_id
122169
data_path: [inRoutePolicy]

internal/provider/data_source_sdwan_service_routing_bgp_feature.go

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,26 +332,26 @@ func (d *ServiceRoutingBGPProfileParcelDataSource) Schema(ctx context.Context, r
332332
MarkdownDescription: "Set IPv4 unicast address family",
333333
Computed: true,
334334
},
335-
"max_number_of_prefixes": schema.Int64Attribute{
335+
"policy_type": schema.StringAttribute{
336+
MarkdownDescription: "Neighbor received maximum prefix policy is disabled.",
337+
Computed: true,
338+
},
339+
"restart_max_number_of_prefixes": schema.Int64Attribute{
336340
MarkdownDescription: "Set maximum number of prefixes accepted from BGP peer",
337341
Computed: true,
338342
},
339-
"max_number_of_prefixes_variable": schema.StringAttribute{
343+
"restart_max_number_of_prefixes_variable": schema.StringAttribute{
340344
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
341345
Computed: true,
342346
},
343-
"threshold": schema.Int64Attribute{
347+
"restart_threshold": schema.Int64Attribute{
344348
MarkdownDescription: "Set threshold(1 to 100) at which to generate a warning message",
345349
Computed: true,
346350
},
347-
"threshold_variable": schema.StringAttribute{
351+
"restart_threshold_variable": schema.StringAttribute{
348352
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
349353
Computed: true,
350354
},
351-
"policy_type": schema.StringAttribute{
352-
MarkdownDescription: "Neighbor received maximum prefix policy is disabled.",
353-
Computed: true,
354-
},
355355
"restart_interval": schema.Int64Attribute{
356356
MarkdownDescription: "Set the restart interval(minutes) when to restart BGP connection if threshold is exceeded",
357357
Computed: true,
@@ -360,6 +360,38 @@ func (d *ServiceRoutingBGPProfileParcelDataSource) Schema(ctx context.Context, r
360360
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
361361
Computed: true,
362362
},
363+
"warning_message_max_number_of_prefixes": schema.Int64Attribute{
364+
MarkdownDescription: "Set maximum number of prefixes accepted from BGP peer",
365+
Computed: true,
366+
},
367+
"warning_message_max_number_of_prefixes_variable": schema.StringAttribute{
368+
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
369+
Computed: true,
370+
},
371+
"warning_message_threshold": schema.Int64Attribute{
372+
MarkdownDescription: "Set threshold(1 to 100) at which to generate a warning message",
373+
Computed: true,
374+
},
375+
"warning_message_threshold_variable": schema.StringAttribute{
376+
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
377+
Computed: true,
378+
},
379+
"disable_peer_max_number_of_prefixes": schema.Int64Attribute{
380+
MarkdownDescription: "Set maximum number of prefixes accepted from BGP peer",
381+
Computed: true,
382+
},
383+
"disable_peer_max_number_of_prefixes_variable": schema.StringAttribute{
384+
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
385+
Computed: true,
386+
},
387+
"disable_peer_threshold": schema.Int64Attribute{
388+
MarkdownDescription: "Set threshold(1 to 100) at which to generate a warning message",
389+
Computed: true,
390+
},
391+
"disable_peer_threshold_variable": schema.StringAttribute{
392+
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
393+
Computed: true,
394+
},
363395
"in_route_policy_id": schema.StringAttribute{
364396
MarkdownDescription: "",
365397
Computed: true,

internal/provider/data_source_sdwan_service_routing_bgp_feature_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ func TestAccDataSourceSdwanServiceRoutingBGPProfileParcel(t *testing.T) {
6363
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.as_override", "false"))
6464
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.allowas_in_number", "1"))
6565
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.family_type", "ipv4-unicast"))
66-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.max_number_of_prefixes", "2000"))
67-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.threshold", "75"))
6866
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.policy_type", "restart"))
67+
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.restart_max_number_of_prefixes", "2000"))
68+
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.restart_threshold", "75"))
6969
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv4_neighbors.0.address_families.0.restart_interval", "30"))
7070
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv6_neighbors.0.address", "2001::1"))
7171
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_routing_bgp_feature.test", "ipv6_neighbors.0.description", "neighbor2"))
@@ -165,9 +165,9 @@ func testAccDataSourceSdwanServiceRoutingBGPProfileParcelConfig() string {
165165
config += ` allowas_in_number = 1` + "\n"
166166
config += ` address_families = [{` + "\n"
167167
config += ` family_type = "ipv4-unicast"` + "\n"
168-
config += ` max_number_of_prefixes = 2000` + "\n"
169-
config += ` threshold = 75` + "\n"
170168
config += ` policy_type = "restart"` + "\n"
169+
config += ` restart_max_number_of_prefixes = 2000` + "\n"
170+
config += ` restart_threshold = 75` + "\n"
171171
config += ` restart_interval = 30` + "\n"
172172
config += ` }]` + "\n"
173173
config += ` }]` + "\n"

0 commit comments

Comments
 (0)