Skip to content

Add Enhanced App Aware Routing Support #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.2

- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source

## 0.6.1

- BREAKING CHANGE: Replaces `no_authentication` attribute of `sdwan_transport_cellular_profile_feature` with `requires_authentication`
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/cisco_system_feature_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ data "sdwan_cisco_system_feature_template" "example" {
- `device_groups_variable` (String) Variable name
- `device_types` (Set of String) List of supported device types
- `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric
- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing
- `geo_fencing` (Boolean) Enable Geo fencing
- `geo_fencing_range` (Number) Set the device’s geo fencing range
- `geo_fencing_range_variable` (String) Variable name
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: |-

# Changelog

## 0.6.2

- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source

## 0.6.1

- BREAKING CHANGE: Replaces `no_authentication` attribute of `sdwan_transport_cellular_profile_feature` with `requires_authentication`
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/cisco_system_feature_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ resource "sdwan_cisco_system_feature_template" "example" {
- `device_groups_variable` (String) Variable name
- `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric
- Choices: `enabled`, `enabled-from-bgp-core`
- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing
- Choices: `disabled`, `aggressive`, `moderate`, `conservative`
- Default value: `disabled`
- `geo_fencing` (Boolean) Enable Geo fencing
- Default value: `false`
- `geo_fencing_range` (Number) Set the device’s geo fencing range
Expand Down
11 changes: 11 additions & 0 deletions gen/definitions/feature_templates/cisco_system.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# Manual resource - Modals toBody and resources Create and Update methods are manually configured to support enhanced_app_aware_routing added in 20.12.
name: Cisco System
minimum_version: 15.0.0
attributes:
Expand Down Expand Up @@ -177,6 +178,16 @@ attributes:
example: 1
- model_name: transport-gateway
example: true
- model_name: epfr
tf_name: enhanced_app_aware_routing
description: Enhanced App Aware Routing
no_augment_config: true
type: String
default_value_present: true
default_value: "disabled"
exclude_test: true
enum_values: ["disabled", "aggressive", "moderate", "conservative"]
example: aggressive
- model_name: enable-mrf-migration
example: enabled
- model_name: migration-bgp-community
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ func (d *CiscoSystemFeatureTemplateDataSource) Schema(ctx context.Context, req d
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"enhanced_app_aware_routing": schema.StringAttribute{
MarkdownDescription: "Enhanced App Aware Routing",
Computed: true,
},
"enable_mrf_migration": schema.StringAttribute{
MarkdownDescription: "Enable migration mode to Multi-Region Fabric",
Computed: true,
Expand Down
40 changes: 35 additions & 5 deletions internal/provider/model_sdwan_cisco_system_feature_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import (
"strconv"

"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)

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

var MinCiscoSytemUpdateVersion = version.Must(version.NewVersion("20.12.0"))

// Section below is generated&owned by "gen/generator.go". //template:begin types
type CiscoSystem struct {
Id types.String `tfsdk:"id"`
Expand Down Expand Up @@ -105,6 +108,7 @@ type CiscoSystem struct {
AffinityGroupPreferenceVariable types.String `tfsdk:"affinity_group_preference_variable"`
TransportGateway types.Bool `tfsdk:"transport_gateway"`
TransportGatewayVariable types.String `tfsdk:"transport_gateway_variable"`
EnhancedAppAwareRouting types.String `tfsdk:"enhanced_app_aware_routing"`
EnableMrfMigration types.String `tfsdk:"enable_mrf_migration"`
MigrationBgpCommunity types.Int64 `tfsdk:"migration_bgp_community"`
}
Expand Down Expand Up @@ -171,9 +175,7 @@ func (data CiscoSystem) getModel() string {
}

// End of section. //template:end getModel

// Section below is generated&owned by "gen/generator.go". //template:begin toBody
func (data CiscoSystem) toBody(ctx context.Context) string {
func (data CiscoSystem) toBody(ctx context.Context, version *version.Version) string {
body := ""

var device_types []string
Expand Down Expand Up @@ -912,6 +914,17 @@ func (data CiscoSystem) toBody(ctx context.Context) string {
body, _ = sjson.Set(body, path+"transport-gateway."+"vipType", "constant")
body, _ = sjson.Set(body, path+"transport-gateway."+"vipValue", strconv.FormatBool(data.TransportGateway.ValueBool()))
}
if version.LessThan(MinCiscoSytemUpdateVersion) {
} else {
if data.EnhancedAppAwareRouting.IsNull() {
body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object")
body, _ = sjson.Set(body, path+"epfr."+"vipType", "ignore")
} else {
body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object")
body, _ = sjson.Set(body, path+"epfr."+"vipType", "constant")
body, _ = sjson.Set(body, path+"epfr."+"vipValue", data.EnhancedAppAwareRouting.ValueString())
}
}
if data.EnableMrfMigration.IsNull() {
body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipObjectType", "object")
body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipType", "ignore")
Expand All @@ -931,8 +944,6 @@ func (data CiscoSystem) toBody(ctx context.Context) string {
return body
}

// End of section. //template:end toBody

// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) {
if value := res.Get("deviceType"); value.Exists() {
Expand Down Expand Up @@ -2004,6 +2015,22 @@ func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) {
data.TransportGateway = types.BoolNull()
data.TransportGatewayVariable = types.StringNull()
}
if value := res.Get(path + "epfr.vipType"); value.Exists() {
if value.String() == "variableName" {
data.EnhancedAppAwareRouting = types.StringNull()

} else if value.String() == "ignore" {
data.EnhancedAppAwareRouting = types.StringNull()

} else if value.String() == "constant" {
v := res.Get(path + "epfr.vipValue")
data.EnhancedAppAwareRouting = types.StringValue(v.String())

}
} else {
data.EnhancedAppAwareRouting = types.StringNull()

}
if value := res.Get(path + "enable-mrf-migration.vipType"); value.Exists() {
if value.String() == "variableName" {
data.EnableMrfMigration = types.StringNull()
Expand Down Expand Up @@ -2223,6 +2250,9 @@ func (data *CiscoSystem) hasChanges(ctx context.Context, state *CiscoSystem) boo
if !data.TransportGateway.Equal(state.TransportGateway) {
hasChanges = true
}
if !data.EnhancedAppAwareRouting.Equal(state.EnhancedAppAwareRouting) {
hasChanges = true
}
if !data.EnableMrfMigration.Equal(state.EnableMrfMigration) {
hasChanges = true
}
Expand Down
21 changes: 13 additions & 8 deletions internal/provider/resource_sdwan_cisco_system_feature_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sync"

"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-plugin-framework-validators/float64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand Down Expand Up @@ -655,6 +656,13 @@ func (r *CiscoSystemFeatureTemplateResource) Schema(ctx context.Context, req res
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Optional: true,
},
"enhanced_app_aware_routing": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Enhanced App Aware Routing").AddStringEnumDescription("disabled", "aggressive", "moderate", "conservative").AddDefaultValueDescription("disabled").String,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("disabled", "aggressive", "moderate", "conservative"),
},
},
"enable_mrf_migration": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Enable migration mode to Multi-Region Fabric").AddStringEnumDescription("enabled", "enabled-from-bgp-core").String,
Optional: true,
Expand Down Expand Up @@ -684,7 +692,6 @@ func (r *CiscoSystemFeatureTemplateResource) Configure(_ context.Context, req re

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

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

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

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

version := version.Must(version.NewVersion(r.client.ManagerVersion))
// Create object
body := plan.toBody(ctx)
body := plan.toBody(ctx, version)

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

// End of section. //template:end create

// Section below is generated&owned by "gen/generator.go". //template:begin read
func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var state CiscoSystem
Expand Down Expand Up @@ -753,7 +759,6 @@ func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resou

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

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

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

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

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

// End of section. //template:end update

// Section below is generated&owned by "gen/generator.go". //template:begin delete
func (r *CiscoSystemFeatureTemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var state CiscoSystem
Expand Down
4 changes: 4 additions & 0 deletions templates/guides/changelog.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: |-

# Changelog

## 0.6.2

- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source

## 0.6.1

- BREAKING CHANGE: Replaces `no_authentication` attribute of `sdwan_transport_cellular_profile_feature` with `requires_authentication`
Expand Down