Skip to content

Commit 3ac9d8e

Browse files
authored
Resolve issue #392 (#455)
1 parent 3d58631 commit 3ac9d8e

File tree

9 files changed

+90
-33
lines changed

9 files changed

+90
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id`
77
- Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478)
88
- Add `sdwan_policy_group` resource and data source
9+
- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source
910

1011
## 0.6.2
1112

docs/data-sources/cisco_system_feature_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ data "sdwan_cisco_system_feature_template" "example" {
4545
- `device_groups_variable` (String) Variable name
4646
- `device_types` (Set of String) List of supported device types
4747
- `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric
48+
- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing
4849
- `geo_fencing` (Boolean) Enable Geo fencing
4950
- `geo_fencing_range` (Number) Set the device’s geo fencing range
5051
- `geo_fencing_range_variable` (String) Variable name

docs/guides/changelog.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
---
2-
subcategory: "Guides"
3-
page_title: "Changelog"
4-
description: |-
5-
Changelog
6-
---
7-
8-
# Changelog
9-
1+
---
2+
subcategory: "Guides"
3+
page_title: "Changelog"
4+
description: |-
5+
Changelog
6+
---
7+
8+
# Changelog
9+
1010
## 0.6.3 (unreleased)
1111

1212
- BREAKING CHANGE: Rename `tls_ssl_profile_version` attribute of `sdwan_tls_ssl_decryption_policy_definition` resource to `tls_ssl_profile_policy_version`
@@ -15,6 +15,7 @@ description: |-
1515
- BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id`
1616
- Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478)
1717
- Add `sdwan_policy_group` resource and data source
18+
- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source
1819

1920
## 0.6.2
2021

@@ -456,4 +457,4 @@ description: |-
456457
## 0.1.0 (July 23, 2021)
457458

458459
- Initial Release
459-
460+

docs/resources/cisco_system_feature_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ resource "sdwan_cisco_system_feature_template" "example" {
109109
- `device_groups_variable` (String) Variable name
110110
- `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric
111111
- Choices: `enabled`, `enabled-from-bgp-core`
112+
- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing
113+
- Choices: `disabled`, `aggressive`, `moderate`, `conservative`
114+
- Default value: `disabled`
112115
- `geo_fencing` (Boolean) Enable Geo fencing
113116
- Default value: `false`
114117
- `geo_fencing_range` (Number) Set the device’s geo fencing range

gen/definitions/feature_templates/cisco_system.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
# Manual resource - Modals toBody and resources Create and Update methods are manually configured to support enhanced_app_aware_routing added in 20.12.
23
name: Cisco System
34
minimum_version: 15.0.0
45
attributes:
@@ -177,6 +178,16 @@ attributes:
177178
example: 1
178179
- model_name: transport-gateway
179180
example: true
181+
- model_name: epfr
182+
tf_name: enhanced_app_aware_routing
183+
description: Enhanced App Aware Routing
184+
no_augment_config: true
185+
type: String
186+
default_value_present: true
187+
default_value: "disabled"
188+
exclude_test: true
189+
enum_values: ["disabled", "aggressive", "moderate", "conservative"]
190+
example: aggressive
180191
- model_name: enable-mrf-migration
181192
example: enabled
182193
- model_name: migration-bgp-community

internal/provider/data_source_sdwan_cisco_system_feature_template.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ func (d *CiscoSystemFeatureTemplateDataSource) Schema(ctx context.Context, req d
545545
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
546546
Computed: true,
547547
},
548+
"enhanced_app_aware_routing": schema.StringAttribute{
549+
MarkdownDescription: "Enhanced App Aware Routing",
550+
Computed: true,
551+
},
548552
"enable_mrf_migration": schema.StringAttribute{
549553
MarkdownDescription: "Enable migration mode to Multi-Region Fabric",
550554
Computed: true,

internal/provider/model_sdwan_cisco_system_feature_template.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ import (
2323
"strconv"
2424

2525
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
26+
"github.com/hashicorp/go-version"
2627
"github.com/hashicorp/terraform-plugin-framework/types"
2728
"github.com/tidwall/gjson"
2829
"github.com/tidwall/sjson"
2930
)
3031

3132
// End of section. //template:end imports
3233

34+
var MinCiscoSytemUpdateVersion = version.Must(version.NewVersion("20.12.0"))
35+
3336
// Section below is generated&owned by "gen/generator.go". //template:begin types
3437
type CiscoSystem struct {
3538
Id types.String `tfsdk:"id"`
@@ -105,6 +108,7 @@ type CiscoSystem struct {
105108
AffinityGroupPreferenceVariable types.String `tfsdk:"affinity_group_preference_variable"`
106109
TransportGateway types.Bool `tfsdk:"transport_gateway"`
107110
TransportGatewayVariable types.String `tfsdk:"transport_gateway_variable"`
111+
EnhancedAppAwareRouting types.String `tfsdk:"enhanced_app_aware_routing"`
108112
EnableMrfMigration types.String `tfsdk:"enable_mrf_migration"`
109113
MigrationBgpCommunity types.Int64 `tfsdk:"migration_bgp_community"`
110114
}
@@ -171,9 +175,7 @@ func (data CiscoSystem) getModel() string {
171175
}
172176

173177
// End of section. //template:end getModel
174-
175-
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
176-
func (data CiscoSystem) toBody(ctx context.Context) string {
178+
func (data CiscoSystem) toBody(ctx context.Context, version *version.Version) string {
177179
body := ""
178180

179181
var device_types []string
@@ -912,6 +914,17 @@ func (data CiscoSystem) toBody(ctx context.Context) string {
912914
body, _ = sjson.Set(body, path+"transport-gateway."+"vipType", "constant")
913915
body, _ = sjson.Set(body, path+"transport-gateway."+"vipValue", strconv.FormatBool(data.TransportGateway.ValueBool()))
914916
}
917+
if version.LessThan(MinCiscoSytemUpdateVersion) {
918+
} else {
919+
if data.EnhancedAppAwareRouting.IsNull() {
920+
body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object")
921+
body, _ = sjson.Set(body, path+"epfr."+"vipType", "ignore")
922+
} else {
923+
body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object")
924+
body, _ = sjson.Set(body, path+"epfr."+"vipType", "constant")
925+
body, _ = sjson.Set(body, path+"epfr."+"vipValue", data.EnhancedAppAwareRouting.ValueString())
926+
}
927+
}
915928
if data.EnableMrfMigration.IsNull() {
916929
body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipObjectType", "object")
917930
body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipType", "ignore")
@@ -931,8 +944,6 @@ func (data CiscoSystem) toBody(ctx context.Context) string {
931944
return body
932945
}
933946

934-
// End of section. //template:end toBody
935-
936947
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
937948
func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) {
938949
if value := res.Get("deviceType"); value.Exists() {
@@ -2004,6 +2015,22 @@ func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) {
20042015
data.TransportGateway = types.BoolNull()
20052016
data.TransportGatewayVariable = types.StringNull()
20062017
}
2018+
if value := res.Get(path + "epfr.vipType"); value.Exists() {
2019+
if value.String() == "variableName" {
2020+
data.EnhancedAppAwareRouting = types.StringNull()
2021+
2022+
} else if value.String() == "ignore" {
2023+
data.EnhancedAppAwareRouting = types.StringNull()
2024+
2025+
} else if value.String() == "constant" {
2026+
v := res.Get(path + "epfr.vipValue")
2027+
data.EnhancedAppAwareRouting = types.StringValue(v.String())
2028+
2029+
}
2030+
} else {
2031+
data.EnhancedAppAwareRouting = types.StringNull()
2032+
2033+
}
20072034
if value := res.Get(path + "enable-mrf-migration.vipType"); value.Exists() {
20082035
if value.String() == "variableName" {
20092036
data.EnableMrfMigration = types.StringNull()
@@ -2223,6 +2250,9 @@ func (data *CiscoSystem) hasChanges(ctx context.Context, state *CiscoSystem) boo
22232250
if !data.TransportGateway.Equal(state.TransportGateway) {
22242251
hasChanges = true
22252252
}
2253+
if !data.EnhancedAppAwareRouting.Equal(state.EnhancedAppAwareRouting) {
2254+
hasChanges = true
2255+
}
22262256
if !data.EnableMrfMigration.Equal(state.EnableMrfMigration) {
22272257
hasChanges = true
22282258
}

internal/provider/resource_sdwan_cisco_system_feature_template.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"sync"
2626

2727
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
28+
"github.com/hashicorp/go-version"
2829
"github.com/hashicorp/terraform-plugin-framework-validators/float64validator"
2930
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
3031
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
@@ -655,6 +656,13 @@ func (r *CiscoSystemFeatureTemplateResource) Schema(ctx context.Context, req res
655656
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
656657
Optional: true,
657658
},
659+
"enhanced_app_aware_routing": schema.StringAttribute{
660+
MarkdownDescription: helpers.NewAttributeDescription("Enhanced App Aware Routing").AddStringEnumDescription("disabled", "aggressive", "moderate", "conservative").AddDefaultValueDescription("disabled").String,
661+
Optional: true,
662+
Validators: []validator.String{
663+
stringvalidator.OneOf("disabled", "aggressive", "moderate", "conservative"),
664+
},
665+
},
658666
"enable_mrf_migration": schema.StringAttribute{
659667
MarkdownDescription: helpers.NewAttributeDescription("Enable migration mode to Multi-Region Fabric").AddStringEnumDescription("enabled", "enabled-from-bgp-core").String,
660668
Optional: true,
@@ -684,7 +692,6 @@ func (r *CiscoSystemFeatureTemplateResource) Configure(_ context.Context, req re
684692

685693
// End of section. //template:end model
686694

687-
// Section below is generated&owned by "gen/generator.go". //template:begin create
688695
func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
689696
var plan CiscoSystem
690697

@@ -697,8 +704,9 @@ func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req res
697704

698705
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString()))
699706

707+
version := version.Must(version.NewVersion(r.client.ManagerVersion))
700708
// Create object
701-
body := plan.toBody(ctx)
709+
body := plan.toBody(ctx, version)
702710

703711
res, err := r.client.Post("/template/feature", body)
704712
if err != nil {
@@ -716,8 +724,6 @@ func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req res
716724
resp.Diagnostics.Append(diags...)
717725
}
718726

719-
// End of section. //template:end create
720-
721727
// Section below is generated&owned by "gen/generator.go". //template:begin read
722728
func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
723729
var state CiscoSystem
@@ -753,7 +759,6 @@ func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resou
753759

754760
// End of section. //template:end read
755761

756-
// Section below is generated&owned by "gen/generator.go". //template:begin update
757762
func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
758763
var plan, state CiscoSystem
759764

@@ -772,7 +777,9 @@ func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req res
772777

773778
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString()))
774779

775-
body := plan.toBody(ctx)
780+
version := version.Must(version.NewVersion(r.client.ManagerVersion))
781+
// Create object
782+
body := plan.toBody(ctx, version)
776783
r.updateMutex.Lock()
777784
res, err := r.client.Put("/template/feature/"+url.QueryEscape(plan.Id.ValueString()), body)
778785
r.updateMutex.Unlock()
@@ -797,8 +804,6 @@ func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req res
797804
resp.Diagnostics.Append(diags...)
798805
}
799806

800-
// End of section. //template:end update
801-
802807
// Section below is generated&owned by "gen/generator.go". //template:begin delete
803808
func (r *CiscoSystemFeatureTemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
804809
var state CiscoSystem

templates/guides/changelog.md.tmpl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
---
2-
subcategory: "Guides"
3-
page_title: "Changelog"
4-
description: |-
5-
Changelog
6-
---
7-
8-
# Changelog
9-
1+
---
2+
subcategory: "Guides"
3+
page_title: "Changelog"
4+
description: |-
5+
Changelog
6+
---
7+
8+
# Changelog
9+
1010
## 0.6.3 (unreleased)
1111

1212
- BREAKING CHANGE: Rename `tls_ssl_profile_version` attribute of `sdwan_tls_ssl_decryption_policy_definition` resource to `tls_ssl_profile_policy_version`
@@ -15,6 +15,7 @@ description: |-
1515
- BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id`
1616
- Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478)
1717
- Add `sdwan_policy_group` resource and data source
18+
- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source
1819

1920
## 0.6.2
2021

@@ -456,4 +457,4 @@ description: |-
456457
## 0.1.0 (July 23, 2021)
457458

458459
- Initial Release
459-
460+

0 commit comments

Comments
 (0)