Skip to content

Commit a23f54e

Browse files
committed
feat(specs): Add spec, tests and examples for panos_qos_policy
1 parent 375d7ee commit a23f54e

File tree

6 files changed

+2179
-0
lines changed

6 files changed

+2179
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The entire QoS policy can be imported by providing the following base64 encoded object as the ID
2+
# {
3+
# location = {
4+
# device_group = {
5+
# name = "example-device-group"
6+
# rulebase = "pre-rulebase"
7+
# panorama_device = "localhost.localdomain"
8+
# }
9+
# }
10+
#
11+
#
12+
# names = [
13+
# "qos-rule-1", <- the first rule in the policy
14+
# ]
15+
# }
16+
terraform import panos_qos_policy.example $(echo '{"location":{"device_group":{"name":"example-device-group","panorama_device":"localhost.localdomain","rulebase":"pre-rulebase"}},"names":["qos-rule-1"]}' | base64)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Manages the entire QoS policy
2+
resource "panos_qos_policy" "example" {
3+
location = {
4+
device_group = {
5+
name = panos_device_group.example.name
6+
}
7+
}
8+
9+
rules = [
10+
{
11+
name = "qos-rule-1"
12+
description = "QoS rule for high priority traffic"
13+
14+
source_zones = ["trust"]
15+
source_addresses = ["any"]
16+
destination_zones = ["untrust"]
17+
destination_addresses = ["any"]
18+
applications = ["ssl"]
19+
services = ["application-default"]
20+
21+
action = {
22+
class = "4"
23+
}
24+
25+
dscp_tos = {
26+
codepoints = [
27+
{
28+
name = "ef-marking"
29+
ef = {
30+
codepoint = "ef"
31+
}
32+
}
33+
]
34+
}
35+
},
36+
{
37+
name = "qos-rule-2"
38+
39+
source_zones = ["any"]
40+
source_addresses = ["any"]
41+
destination_zones = ["any"]
42+
destination_addresses = ["any"]
43+
applications = ["any"]
44+
services = ["any"]
45+
46+
action = {
47+
class = "1"
48+
}
49+
}
50+
]
51+
}
52+
53+
resource "panos_device_group" "example" {
54+
location = {
55+
panorama = {}
56+
}
57+
58+
name = "example-device-group"
59+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# A set of QoS rules can be imported by providing the following base64 encoded object as the ID
2+
# {
3+
# location = {
4+
# device_group = {
5+
# name = "example-device-group"
6+
# rulebase = "pre-rulebase"
7+
# panorama_device = "localhost.localdomain"
8+
# }
9+
# }
10+
#
11+
# position = { where = "after", directly = true, pivot = "existing-rule" }
12+
#
13+
# names = [
14+
# "qos-rule-8",
15+
# "qos-rule-9"
16+
# ]
17+
# }
18+
terraform import panos_qos_policy_rules.example $(echo '{"location":{"device_group":{"name":"example-device-group","panorama_device":"localhost.localdomain","rulebase":"pre-rulebase"}},"names":["qos-rule-8","qos-rule-9"],"position":{"directly":true,"pivot":"existing-rule","where":"after"}}' | base64)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Manage a group of QoS policy rules.
2+
3+
## Place the rule group at the top
4+
resource "panos_qos_policy_rules" "example-1" {
5+
location = {
6+
device_group = {
7+
name = panos_device_group.example.name
8+
}
9+
}
10+
11+
position = {
12+
where = "first" # first, last, after, before
13+
}
14+
15+
rules = [
16+
{
17+
name = "qos-rule-1"
18+
description = "High priority VoIP traffic"
19+
20+
source_zones = ["trust"]
21+
source_addresses = ["any"]
22+
destination_zones = ["untrust"]
23+
destination_addresses = ["any"]
24+
applications = ["sip", "h323"]
25+
services = ["application-default"]
26+
27+
action = {
28+
class = "7"
29+
}
30+
31+
dscp_tos = {
32+
codepoints = [
33+
{
34+
name = "ef-marking"
35+
ef = {
36+
codepoint = "ef"
37+
}
38+
}
39+
]
40+
}
41+
}
42+
]
43+
}
44+
45+
## Place the rule group directly after an existing rule
46+
resource "panos_qos_policy_rules" "example-2" {
47+
location = {
48+
device_group = {
49+
name = panos_device_group.example.name
50+
}
51+
}
52+
53+
position = { where = "after", directly = true, pivot = "existing-rule" }
54+
55+
rules = [for k in ["web", "database", "default"] :
56+
{
57+
name = "qos-${k}"
58+
59+
source_zones = ["any"]
60+
source_addresses = ["any"]
61+
destination_zones = ["any"]
62+
destination_addresses = ["any"]
63+
applications = ["any"]
64+
services = ["any"]
65+
66+
action = {
67+
class = k == "web" ? "5" : k == "database" ? "4" : "1"
68+
}
69+
70+
dscp_tos = {
71+
codepoints = [
72+
{
73+
name = "${k}-codepoint"
74+
af = {
75+
codepoint = k == "web" ? "af21" : k == "database" ? "af31" : "af11"
76+
}
77+
}
78+
]
79+
}
80+
}
81+
]
82+
}
83+
84+
resource "panos_device_group" "example" {
85+
location = {
86+
panorama = {}
87+
}
88+
89+
name = "example-device-group"
90+
}

0 commit comments

Comments
 (0)