Skip to content

Commit 7e1938b

Browse files
lizhijianrdmssonicbld
authored andcommitted
[YANG SONIC-ACL] Fix Yang definition of ACL_TABLE_TYPE (sonic-net#16247)
How I did it Update Yang definition of ACL_TABLE_TYPE. Update existing testcase. Add new testcase to cover lowercase key scenario. How to verify it Verified by building sonic_yang_models-1.0-py3-none-any.whl. While building the target package, unit tests were run and passed.
1 parent a49860c commit 7e1938b

File tree

5 files changed

+69
-15
lines changed

5 files changed

+69
-15
lines changed

src/sonic-yang-models/tests/files/sample_config_db.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2302,18 +2302,18 @@
23022302
},
23032303
"ACL_TABLE_TYPE": {
23042304
"CUSTOM_L3": {
2305-
"matches": [
2305+
"MATCHES": [
23062306
"IN_PORTS",
23072307
"OUT_PORTS",
23082308
"SRC_IP",
23092309
"BTH_OPCODE",
23102310
"AETH_SYNDROME"
23112311
],
2312-
"actions": [
2312+
"ACTIONS": [
23132313
"PACKET_ACTION",
23142314
"MIRROR_INGRESS_ACTION"
23152315
],
2316-
"bind_points": [
2316+
"BIND_POINTS": [
23172317
"PORT",
23182318
"LAG"
23192319
]

src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def initTest(self):
4848
'Range': ['does not satisfy', 'range'],
4949
'MinElements': ['Too few'],
5050
'MaxElements': ['Too many'],
51+
'UnknownElement': ['Unknown element'],
5152
'None': []
5253
}
5354

src/sonic-yang-models/tests/yang_model_tests/tests/acl.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@
9898
"eStrKey": "MinElements"
9999
},
100100
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
101-
"desc": "ACL_TABLE LOAD TABLE TYPE SUCCESSFULLY WITH NO ACTIONS.",
101+
"desc": "ACL_TABLE LOAD TABLE TYPE WITH NO ACTIONS.",
102102
"eStrKey" : "Verify",
103103
"verify": {
104104
"xpath": "/sonic-acl:sonic-acl/ACL_TABLE_TYPE/ACL_TABLE_TYPE_LIST[ACL_TABLE_TYPE_NAME='CUSTOM_L3']/ACL_TABLE_TYPE_NAME",
105-
"key": "sonic-acl:actions",
105+
"key": "sonic-acl:ACTIONS",
106106
"value": [""]
107107
}
108108
},
109+
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
110+
"desc": "ACL_TABLE LOAD TABLE TYPE WITH KEY ACTIONS/BIND_POINTS/MATCHES WRITTEN IN LOWERCASE.",
111+
"eStrKey": "UnknownElement"
112+
},
109113
"ACL_TABLE_L2_ACL_FIELDS": {
110114
"desc": "Configure L2 ACL with proper rule fields"
111115
},

src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json

+56-7
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,14 @@
723723
"ACL_TABLE_TYPE_LIST": [
724724
{
725725
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
726-
"matches": [
726+
"MATCHES": [
727727
"SRC_IP",
728728
"IN_PORTS"
729729
],
730-
"actions": [
730+
"ACTIONS": [
731731
"PACKET_ACTION"
732732
],
733-
"bind_points": [
733+
"BIND_POINTS": [
734734
"PORT"
735735
]
736736
}
@@ -772,10 +772,10 @@
772772
"ACL_TABLE_TYPE_LIST": [
773773
{
774774
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
775-
"actions": [
775+
"ACTIONS": [
776776
"PACKET_ACTION"
777777
],
778-
"bind_points": [
778+
"BIND_POINTS": [
779779
"PORT"
780780
]
781781
}
@@ -817,11 +817,11 @@
817817
"ACL_TABLE_TYPE_LIST": [
818818
{
819819
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
820-
"matches": [
820+
"MATCHES": [
821821
"SRC_IP",
822822
"IN_PORTS"
823823
],
824-
"actions": [
824+
"ACTIONS": [
825825
"PACKET_ACTION"
826826
]
827827
}
@@ -845,6 +845,52 @@
845845
}
846846
},
847847
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
848+
"sonic-acl:sonic-acl": {
849+
"sonic-acl:ACL_TABLE": {
850+
"ACL_TABLE_LIST": [
851+
{
852+
"ACL_TABLE_NAME": "NO-NSW-PACL-V6",
853+
"policy_desc": "Filter IPv6",
854+
"ports": [
855+
"Ethernet0"
856+
],
857+
"stage": "EGRESS",
858+
"type": "CUSTOM_L3"
859+
}
860+
]
861+
},
862+
"sonic-acl:ACL_TABLE_TYPE": {
863+
"ACL_TABLE_TYPE_LIST": [
864+
{
865+
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
866+
"MATCHES": [
867+
"SRC_IP",
868+
"IN_PORTS"
869+
],
870+
"BIND_POINTS": [
871+
"PORT"
872+
]
873+
}
874+
]
875+
}
876+
},
877+
"sonic-port:sonic-port": {
878+
"sonic-port:PORT": {
879+
"PORT_LIST": [
880+
{
881+
"admin_status": "up",
882+
"alias": "eth0",
883+
"description": "Ethernet0",
884+
"lanes": "0,1,2,3",
885+
"mtu": 9000,
886+
"name": "Ethernet0",
887+
"speed": 25000
888+
}
889+
]
890+
}
891+
}
892+
},
893+
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
848894
"sonic-acl:sonic-acl": {
849895
"sonic-acl:ACL_TABLE": {
850896
"ACL_TABLE_LIST": [
@@ -867,6 +913,9 @@
867913
"SRC_IP",
868914
"IN_PORTS"
869915
],
916+
"actions": [
917+
"PACKET_ACTION"
918+
],
870919
"bind_points": [
871920
"PORT"
872921
]

src/sonic-yang-models/yang-templates/sonic-acl.yang.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ module sonic-acl {
295295
type string;
296296
}
297297

298-
leaf-list matches {
298+
leaf-list MATCHES {
299299
type string;
300300
min-elements 1;
301301
}
302302

303-
leaf-list actions {
303+
leaf-list ACTIONS {
304304
type string;
305305
default "";
306306
}
307307

308-
leaf-list bind_points {
308+
leaf-list BIND_POINTS {
309309
type enumeration {
310310
enum PORT;
311311
enum LAG;

0 commit comments

Comments
 (0)