Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 0.8.2 (Unreleased)

- Add `sdwan_system_ca_certificate_feature` resource and data source
- Add `tunnel_bandwidth` attribute, which is automatically included when `tunnel_qos_mode` is set to `hub` in the `sdwan_cisco_vpn_interface_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- Add `service` attribute, which is now automatically included when a `prefix` is configured under `ipv4_static_service_routes` in the `sdwan_cisco_vpn_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- BREAKING CHANGE: Refactor `max_number_of_prefixes`, `restart_interval` and `threshold` parameters under `ipv6_neighbors` section of `sdwan_service_routing_bgp_feature` and `sdwan_transport_routing_bgp_feature` resource
- Add default value for `administrative_distance` in `sdwan_transport_wan_vpn_feature`
- Fix issue where `fallback` in `sdwan_traffic_data_policy_definition` configuration is not applied correctly, causing the GUI to display it as enabled even when disabled in Terraform
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ description: |-
## 0.8.2 (Unreleased)

- Add `sdwan_system_ca_certificate_feature` resource and data source
- Add `tunnel_bandwidth` attribute, which is automatically included when `tunnel_qos_mode` is set to `hub` in the `sdwan_cisco_vpn_interface_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- Add `service` attribute, which is now automatically included when a `prefix` is configured under `ipv4_static_service_routes` in the `sdwan_cisco_vpn_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- BREAKING CHANGE: Refactor `max_number_of_prefixes`, `restart_interval` and `threshold` parameters under `ipv6_neighbors` section of `sdwan_service_routing_bgp_feature` and `sdwan_transport_routing_bgp_feature` resource
- Add default value for `administrative_distance` in `sdwan_transport_wan_vpn_feature`
- Fix issue where `fallback` in `sdwan_traffic_data_policy_definition` configuration is not applied correctly, causing the GUI to display it as enabled even when disabled in Terraform
Expand Down
4 changes: 4 additions & 0 deletions gen/definitions/feature_templates/cisco_vpn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ attributes:
example: 2
- model_name: service
example: sig
include_default_option: true
conditional_attribute:
name: prefix
value: ''
- model_name: route
data_path: [ip]
tf_name: ipv4_static_routes
Expand Down
4 changes: 4 additions & 0 deletions gen/definitions/feature_templates/cisco_vpn_interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ attributes:
tf_name: tunnel_bandwidth
exclude_ignore: true
example: 50
include_default_option: true
conditional_attribute:
name: tunnel_qos_mode
value: hub
- model_name: group
tf_name: tunnel_interface_groups
exclude_ignore: true
Expand Down
5 changes: 5 additions & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ type YamlConfigAttribute struct {
RequiresReplace bool `yaml:"requires_replace"`
DynamicDefault bool `yaml:"dynamic_default"`
PriorityOrderAlways bool `yaml:"priority_order_always"`
IncludeDefaultOption bool `yaml:"include_default_option"`
DefaultOption string `yaml:"default_option"`
}

type YamlConfigConditionalAttribute struct {
Expand Down Expand Up @@ -715,6 +717,9 @@ func parseFeatureTemplateAttribute(attr *YamlConfigAttribute, model gjson.Result
if r.Get("dataType.default").Exists() {
attr.DefaultValue = r.Get("dataType.default").String()
}
if r.Get("defaultOption").Exists() {
attr.DefaultOption = r.Get("defaultOption").String()
}
types := r.Get("optionType").Array()
ignore := false
variable := false
Expand Down
1 change: 1 addition & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ attribute:
requires_replace: bool(required=False) # If true resource will be recreated when attribute is changed
dynamic_default: bool(required=False) # If true when the provided value matches the default value `optionType` will be set to `default` rather than `global`
priority_order_always: bool(required=False) # If true will always set priority-order in feature template payload
include_default_option: bool(required=False) # If true will always include the default option type in the payload when the attribute value is null

conditional_attribute:
name: str() # Reference to other attribute
Expand Down
26 changes: 19 additions & 7 deletions gen/templates/feature_templates/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
{{- else if ( .IncludeDefaultOption)}}
if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Value ""}} && !data.{{toGoName .ConditionalAttribute.Name}}.IsNull() {{else if eq .ConditionalAttribute.Type "Bool"}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} {
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "{{.DefaultOption}}")
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", {{if eq .Type "String"}} "{{.DefaultValue}}" {{else}} {{.DefaultValue}} {{end}})
}
{{- else if and (.DataPath) (not .ExcludeIgnore)}}
if !gjson.Get(body, path+"{{path .DataPath}}").Exists() {
body, _ = sjson.Set(body, path+"{{path .DataPath}}", map[string]interface{}{})
Expand Down Expand Up @@ -262,7 +268,13 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "ignore")
{{- else if and (.DataPath) (not .ExcludeIgnore)}}
{{- else if ( .IncludeDefaultOption)}}
if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Value ""}} && !item.{{toGoName .ConditionalAttribute.Name}}.IsNull() {{else if eq .ConditionalAttribute.Type "Bool"}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} {
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "{{.DefaultOption}}")
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", {{if eq .Type "String"}} "{{.DefaultValue}}" {{else}} {{.DefaultValue}} {{end}})
}
{{- else if and (.DataPath) (not .ExcludeIgnore)}}
if !gjson.Get(itemBody, "{{path .DataPath}}").Exists() {
itemBody, _ = sjson.Set(itemBody, "{{path .DataPath}}", map[string]interface{}{})
}
Expand Down Expand Up @@ -608,7 +620,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
{{end}}
} else if value.String() == "ignore" {
} else if value.String() == "ignore" {{if .IncludeDefaultOption}} || value.String() == "notIgnore" {{end}} {
data.{{toGoName .TfName}} = types.StringNull()
{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if value.String() == "constant" {
Expand All @@ -628,7 +640,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
{{end}}
} else if value.String() == "ignore" {
} else if value.String() == "ignore" {{if .IncludeDefaultOption}} || value.String() == "notIgnore" {{end}} {
data.{{toGoName .TfName}} = types.Int64Null()
{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if value.String() == "constant" {
Expand All @@ -648,7 +660,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
v := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
data.{{toGoName .TfName}}Variable = types.StringValue(v.String())
{{end}}
} else if value.String() == "ignore" {
} else if value.String() == "ignore" {{if .IncludeDefaultOption}} || value.String() == "notIgnore" {{end}} {
data.{{toGoName .TfName}} = types.Float64Null()
{{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if value.String() == "constant" {
Expand Down Expand Up @@ -729,7 +741,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
{{end}}
} else if cValue.String() == "ignore" {
} else if cValue.String() == "ignore" {{if .IncludeDefaultOption}} || cValue.String() == "notIgnore" {{end}} {
item.{{toGoName .TfName}} = types.StringNull()
{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if cValue.String() == "constant" {
Expand All @@ -749,7 +761,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
{{end}}
} else if cValue.String() == "ignore" {
} else if cValue.String() == "ignore" {{if .IncludeDefaultOption}} || cValue.String() == "notIgnore" {{end}} {
item.{{toGoName .TfName}} = types.Int64Null()
{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if cValue.String() == "constant" {
Expand All @@ -769,7 +781,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
cv := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.vipVariableName")
item.{{toGoName .TfName}}Variable = types.StringValue(cv.String())
{{end}}
} else if cValue.String() == "ignore" {
} else if cValue.String() == "ignore" {{if .IncludeDefaultOption}} || cValue.String() == "notIgnore" {{end}} {
item.{{toGoName .TfName}} = types.Float64Null()
{{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}}
} else if cValue.String() == "constant" {
Expand Down
7 changes: 6 additions & 1 deletion internal/provider/model_sdwan_cisco_vpn_feature_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ func (data CiscoVPN) toBody(ctx context.Context) string {
}
itemAttributes = append(itemAttributes, "service")
if item.Service.IsNull() {
if true && !item.Prefix.IsNull() {
itemBody, _ = sjson.Set(itemBody, "service."+"vipObjectType", "object")
itemBody, _ = sjson.Set(itemBody, "service."+"vipType", "notIgnore")
itemBody, _ = sjson.Set(itemBody, "service."+"vipValue", "sig")
}
} else {
itemBody, _ = sjson.Set(itemBody, "service."+"vipObjectType", "object")
itemBody, _ = sjson.Set(itemBody, "service."+"vipType", "constant")
Expand Down Expand Up @@ -2534,7 +2539,7 @@ func (data *CiscoVPN) fromBody(ctx context.Context, res gjson.Result) {
if cValue.String() == "variableName" {
item.Service = types.StringNull()

} else if cValue.String() == "ignore" {
} else if cValue.String() == "ignore" || cValue.String() == "notIgnore" {
item.Service = types.StringNull()

} else if cValue.String() == "constant" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,11 @@ func (data CiscoVPNInterface) toBody(ctx context.Context) string {
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipType", "variableName")
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipVariableName", data.TunnelBandwidthVariable.ValueString())
} else if data.TunnelBandwidth.IsNull() {
if true && data.TunnelQosMode.ValueString() == "hub" {
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipObjectType", "object")
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipType", "notIgnore")
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipValue", 50)
}
} else {
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipObjectType", "object")
body, _ = sjson.Set(body, path+"tunnel-interface.tunnels-bandwidth."+"vipType", "constant")
Expand Down Expand Up @@ -3569,7 +3574,7 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) {
v := res.Get(path + "tunnel-interface.tunnels-bandwidth.vipVariableName")
data.TunnelBandwidthVariable = types.StringValue(v.String())

} else if value.String() == "ignore" {
} else if value.String() == "ignore" || value.String() == "notIgnore" {
data.TunnelBandwidth = types.Int64Null()
data.TunnelBandwidthVariable = types.StringNull()
} else if value.String() == "constant" {
Expand Down
2 changes: 2 additions & 0 deletions templates/guides/changelog.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ description: |-
## 0.8.2 (Unreleased)

- Add `sdwan_system_ca_certificate_feature` resource and data source
- Add `tunnel_bandwidth` attribute, which is automatically included when `tunnel_qos_mode` is set to `hub` in the `sdwan_cisco_vpn_interface_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- Add `service` attribute, which is now automatically included when a `prefix` is configured under `ipv4_static_service_routes` in the `sdwan_cisco_vpn_feature_template` resource, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/429)
- BREAKING CHANGE: Refactor `max_number_of_prefixes`, `restart_interval` and `threshold` parameters under `ipv6_neighbors` section of `sdwan_service_routing_bgp_feature` and `sdwan_transport_routing_bgp_feature` resource
- Add default value for `administrative_distance` in `sdwan_transport_wan_vpn_feature`
- Fix issue where `fallback` in `sdwan_traffic_data_policy_definition` configuration is not applied correctly, causing the GUI to display it as enabled even when disabled in Terraform
Expand Down