Skip to content

Commit

Permalink
Add attributes to policy map resource
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Jan 11, 2024
1 parent 497ce9f commit 39c4daf
Show file tree
Hide file tree
Showing 14 changed files with 933 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add `bandwidth` attribute to `iosxe_interface_ethernet` resource and data source
- Add `speed_nonegotiate` attribute to `iosxe_interface_ethernet` resource and data source
- Add `service_policy_input` and `service_policy_output` attributes to `iosxe_interface_ethernet` resource and data source
- Add `classes` and `description` attributes to `iosxe_policy_map` resource and data source

## 0.5.4

Expand Down
34 changes: 33 additions & 1 deletion docs/data-sources/policy_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This data source can read the Policy Map configuration.

```terraform
data "iosxe_policy_map" "example" {
name = "dot1x_policy"
name = "POLICY1"
}
```

Expand All @@ -31,6 +31,38 @@ data "iosxe_policy_map" "example" {

### Read-Only

- `classes` (Attributes List) policy criteria (see [below for nested schema](#nestedatt--classes))
- `description` (String) Policy-Map description
- `id` (String) The path of the retrieved object.
- `subscriber` (Boolean) Domain name of the policy map
- `type` (String) type of the policy-map

<a id="nestedatt--classes"></a>
### Nested Schema for `classes`

Read-Only:

- `actions` (Attributes List) (see [below for nested schema](#nestedatt--classes--actions))
- `name` (String)

<a id="nestedatt--classes--actions"></a>
### Nested Schema for `classes.actions`

Read-Only:

- `bandwidth_bits` (Number)
- `bandwidth_percent` (Number) % of total Bandwidth
- `bandwidth_remaining_option` (String)
- `bandwidth_remaining_percent` (Number) % of the remaining bandwidth
- `bandwidth_remaining_ratio` (Number) ratio for sharing excess bandwidth
- `priority_burst` (Number)
- `priority_level` (Number) Multi-Level Priority Queue
- `queue_limit` (Number)
- `queue_limit_type` (String)
- `shape_average_bit_rate` (Number) Target Bit Rate (bits/sec)
- `shape_average_bits_per_interval_excess` (Number) bits per interval, excess.
- `shape_average_bits_per_interval_sustained` (Number) bits per interval, sustained. Recommend not to configure, algo finds the best value
- `shape_average_burst_size_sustained` (Number) sustained burst in milliseconds. Recommend not to configure it, the algorithm will find out the best value
- `shape_average_ms` (Boolean) milliseconds
- `shape_average_percent` (Number) % of interface bandwidth for Committed information rate
- `type` (String)
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description: |-
- Add `bandwidth` attribute to `iosxe_interface_ethernet` resource and data source
- Add `speed_nonegotiate` attribute to `iosxe_interface_ethernet` resource and data source
- Add `service_policy_input` and `service_policy_output` attributes to `iosxe_interface_ethernet` resource and data source
- Add `classes` and `description` attributes to `iosxe_policy_map` resource and data source

## 0.5.4

Expand Down
65 changes: 61 additions & 4 deletions docs/resources/policy_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ This resource can manage the Policy Map configuration.

```terraform
resource "iosxe_policy_map" "example" {
name = "dot1x_policy"
type = "control"
subscriber = true
name = "POLICY1"
description = "My first policy-map"
classes = [
{
name = "CLASS1"
actions = [
{
type = "bandwidth"
bandwidth_percent = 10
}
]
}
]
}
```

Expand All @@ -29,6 +39,8 @@ resource "iosxe_policy_map" "example" {

### Optional

- `classes` (Attributes List) policy criteria (see [below for nested schema](#nestedatt--classes))
- `description` (String) Policy-Map description
- `device` (String) A device name from the provider configuration.
- `subscriber` (Boolean) Domain name of the policy map
- `type` (String) type of the policy-map
Expand All @@ -38,10 +50,55 @@ resource "iosxe_policy_map" "example" {

- `id` (String) The path of the object.

<a id="nestedatt--classes"></a>
### Nested Schema for `classes`

Required:

- `name` (String)

Optional:

- `actions` (Attributes List) (see [below for nested schema](#nestedatt--classes--actions))

<a id="nestedatt--classes--actions"></a>
### Nested Schema for `classes.actions`

Required:

- `type` (String) - Choices: `bandwidth`, `compression`, `dbl`, `drop`, `estimate`, `fair-queue`, `forward`, `netflow-sampler`, `police`, `priority`, `queue-buffers`, `queue-limit`, `random-detect`, `service-policy`, `set`, `shape`, `trust`

Optional:

- `bandwidth_bits` (Number) - Range: `1`-`100000000`
- `bandwidth_percent` (Number) % of total Bandwidth
- Range: `1`-`100`
- `bandwidth_remaining_option` (String) - Choices: `percent`, `ratio`
- `bandwidth_remaining_percent` (Number) % of the remaining bandwidth
- Range: `1`-`100`
- `bandwidth_remaining_ratio` (Number) ratio for sharing excess bandwidth
- Range: `1`-`65536`
- `priority_burst` (Number) - Range: `32`-`2000000`
- `priority_level` (Number) Multi-Level Priority Queue
- Range: `1`-`2`
- `queue_limit` (Number) - Range: `1`-`64000000`
- `queue_limit_type` (String) - Choices: `bytes`, `ms`, `packets`, `us`
- `shape_average_bit_rate` (Number) Target Bit Rate (bits/sec)
- Range: `8000`-`100000000000`
- `shape_average_bits_per_interval_excess` (Number) bits per interval, excess.
- Range: `0`-`154400000`
- `shape_average_bits_per_interval_sustained` (Number) bits per interval, sustained. Recommend not to configure, algo finds the best value
- Range: `256`-`154400000`
- `shape_average_burst_size_sustained` (Number) sustained burst in milliseconds. Recommend not to configure it, the algorithm will find out the best value
- Range: `10`-`2000`
- `shape_average_ms` (Boolean) milliseconds
- `shape_average_percent` (Number) % of interface bandwidth for Committed information rate
- Range: `0`-`100`

## Import

Import is supported using the following syntax:

```shell
terraform import iosxe_policy_map.example "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
terraform import iosxe_policy_map.example "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=POLICY1"
```
2 changes: 1 addition & 1 deletion examples/data-sources/iosxe_policy_map/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data "iosxe_policy_map" "example" {
name = "dot1x_policy"
name = "POLICY1"
}
2 changes: 1 addition & 1 deletion examples/resources/iosxe_policy_map/import.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform import iosxe_policy_map.example "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
terraform import iosxe_policy_map.example "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=POLICY1"
16 changes: 13 additions & 3 deletions examples/resources/iosxe_policy_map/resource.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
resource "iosxe_policy_map" "example" {
name = "dot1x_policy"
type = "control"
subscriber = true
name = "POLICY1"
description = "My first policy-map"
classes = [
{
name = "CLASS1"
actions = [
{
type = "bandwidth"
bandwidth_percent = 10
}
]
}
]
}
103 changes: 102 additions & 1 deletion gen/definitions/policy_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,109 @@ no_delete_attributes: true
attributes:
- yang_name: name
id: true
example: dot1x_policy
example: POLICY1
- yang_name: type
example: control
exclude_test: true
- yang_name: subscriber
example: true
exclude_test: true
- yang_name: description
example: My first policy-map
- yang_name: class
tf_name: classes
type: List
attributes:
- yang_name: name
id: true
example: CLASS1
- yang_name: action-list
tf_name: actions
type: List
attributes:
- yang_name: action-type
tf_name: type
id: true
example: bandwidth
- yang_name: action-param/bandwidth-case/bandwidth/bits
xpath: bandwidth/bits
tf_name: bandwidth_bits
example: 1000000
exclude_test: true
- yang_name: action-param/bandwidth-case/bandwidth/percent
xpath: bandwidth/percent
tf_name: bandwidth_percent
example: 10
- yang_name: action-param/bandwidth-case/bandwidth/remaining/rem-option
xpath: bandwidth/remaining/rem-option
tf_name: bandwidth_remaining_option
example: percent
exclude_test: true
- yang_name: action-param/bandwidth-case/bandwidth/remaining/percent
xpath: bandwidth/remaining/percent
tf_name: bandwidth_remaining_percent
example: 10
exclude_test: true
- yang_name: action-param/bandwidth-case/bandwidth/remaining/ratio
xpath: bandwidth/remaining/ratio
tf_name: bandwidth_remaining_ratio
example: 100
exclude_test: true
- yang_name: action-param/priority-case/priority/level
xpath: priority/level
tf_name: priority_level
example: 1
exclude_test: true
- yang_name: action-param/priority-case/priority/burst
xpath: priority/burst
tf_name: priority_burst
example: 10000
exclude_test: true
- yang_name: action-param/queue-limit-case/queue-limit/queue-limit-value
xpath: queue-limit/queue-limit-value
tf_name: queue_limit
example: 10000
exclude_test: true
- yang_name: action-param/queue-limit-case/queue-limit/queue-limit-type
xpath: queue-limit/queue-limit-type
tf_name: queue_limit_type
example: ms
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/a/bit-rate
xpath: shape/average/bit-rate
tf_name: shape_average_bit_rate
example: 1000
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/a/bits-per-interval-sustained
xpath: shape/average/bits-per-interval-sustained
tf_name: shape_average_bits_per_interval_sustained
example: 1000
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/a/bits-per-interval-excess
xpath: shape/average/bits-per-interval-excess
tf_name: shape_average_bits_per_interval_excess
example: 1000
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/b/percent
xpath: shape/average/percent
tf_name: shape_average_percent
example: 10
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/b/burst-size-sustained
xpath: shape/average/burst-size-sustained
tf_name: shape_average_burst_size_sustained
example: 1000
exclude_test: true
- yang_name: action-param/shape-case/shape/average/average-choice/b/ms
xpath: shape/average/ms
tf_name: shape_average_ms
example: 1000
exclude_test: true

test_prerequisites:
- path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=CLASS1
attributes:
- name: name
value: CLASS1
- name: prematch
value: match-all
88 changes: 88 additions & 0 deletions internal/provider/data_source_iosxe_policy_map.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 39c4daf

Please sign in to comment.