Skip to content

Commit 3aa48b1

Browse files
zbud-msftmssonicbld
authored andcommitted
[yang] Change swss-event, dhcp-relay-event leafref to string (sonic-net#13326)
Why I did it Do not require leafref as part of yang. Only need string to compare whether string received from event matches what is possible for ifname. How I did it How to verify it Run UT
1 parent bc1688c commit 3aa48b1

6 files changed

Lines changed: 11 additions & 244 deletions

File tree

src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-dhcp-relay.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_IFNAME": {
33
"desc": "DHCP_RELAY_DISCARD_EVENT_INCORRECT_IFNAME failure.",
4-
"eStrKey": "InvalidValue",
5-
"eStr": ["Eth"]
4+
"eStrKey": "Pattern"
65
},
76
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_TIMESTAMP": {
87
"desc": "DHCP_RELAY_DISCARD_EVENT_INCORRECT_TIMESTAMP failure.",

src/sonic-yang-models/tests/yang_model_tests/tests/sonic-events-swss.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"SONIC_EVENTS_SWSS_IF_STATE_INCORRECT_IFNAME": {
33
"desc": "IF_STATE_EVENT_INCORRECT_IFNAME failure.",
4-
"eStrKey": "LeafRef",
5-
"eStr": ["Eth"]
4+
"eStrKey": "Pattern"
65
},
76
"SONIC_EVENTS_SWSS_IF_STATE_INCORRECT_STATUS": {
87
"desc": "IF_STATE_EVENT_INCORRECT_STATUS failure.",
@@ -17,8 +16,7 @@
1716
},
1817
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_IFNAME": {
1918
"desc": "PFC_STORM_EVENT_INCORRECT_IFNAME failure.",
20-
"eStrKey": "LeafRef",
21-
"eStr": ["Eth"]
19+
"eStrKey": "Pattern"
2220
},
2321
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_QUEUE_INDEX": {
2422
"desc": "PFC_STORM_EVENT_INCORRECT_QUEUE_INDEX failure.",

src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-dhcp-relay.json

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
{
22
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_IFNAME": {
3-
"sonic-port:sonic-port": {
4-
"sonic-port:PORT": {
5-
"PORT_LIST": [
6-
{
7-
"admin_status": "up",
8-
"alias": "eth0",
9-
"description": "Ethernet0",
10-
"lanes": 65,
11-
"mtu": 9000,
12-
"name": "Ethernet0",
13-
"speed": 25000
14-
}
15-
]
16-
}
17-
},
18-
"sonic-portchannel:sonic-portchannel": {
19-
"sonic-portchannel:PORTCHANNEL": {
20-
"PORTCHANNEL_LIST": [
21-
{
22-
"admin_status": "up",
23-
"name": "PortChannel10"
24-
}
25-
]
26-
}
27-
},
283
"sonic-events-dhcp-relay:sonic-events-dhcp-relay": {
294
"sonic-events-dhcp-relay:dhcp-relay-discard": {
305
"ifname": "Eth",
@@ -33,31 +8,6 @@
338
}
349
},
3510
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_TIMESTAMP": {
36-
"sonic-port:sonic-port": {
37-
"sonic-port:PORT": {
38-
"PORT_LIST": [
39-
{
40-
"admin_status": "up",
41-
"alias": "eth0",
42-
"description": "Ethernet0",
43-
"lanes": 65,
44-
"mtu": 9000,
45-
"name": "Ethernet0",
46-
"speed": 25000
47-
}
48-
]
49-
}
50-
},
51-
"sonic-portchannel:sonic-portchannel": {
52-
"sonic-portchannel:PORTCHANNEL": {
53-
"PORTCHANNEL_LIST": [
54-
{
55-
"admin_status": "up",
56-
"name": "PortChannel10"
57-
}
58-
]
59-
}
60-
},
6111
"sonic-events-dhcp-relay:sonic-events-dhcp-relay": {
6212
"sonic-events-dhcp-relay:dhcp-relay-discard": {
6313
"ifname": "Ethernet0",
@@ -66,31 +16,6 @@
6616
}
6717
},
6818
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_VALID": {
69-
"sonic-port:sonic-port": {
70-
"sonic-port:PORT": {
71-
"PORT_LIST": [
72-
{
73-
"admin_status": "up",
74-
"alias": "eth0",
75-
"description": "Ethernet0",
76-
"lanes": 65,
77-
"mtu": 9000,
78-
"name": "Ethernet0",
79-
"speed": 25000
80-
}
81-
]
82-
}
83-
},
84-
"sonic-portchannel:sonic-portchannel": {
85-
"sonic-portchannel:PORTCHANNEL": {
86-
"PORTCHANNEL_LIST": [
87-
{
88-
"admin_status": "up",
89-
"name": "PortChannel10"
90-
}
91-
]
92-
}
93-
},
9419
"sonic-events-dhcp-relay:sonic-events-dhcp-relay": {
9520
"sonic-events-dhcp-relay:dhcp-relay-discard": {
9621
"ifname": "Ethernet0",

src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-swss.json

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
{
22
"SONIC_EVENTS_SWSS_IF_STATE_INCORRECT_IFNAME": {
3-
"sonic-port:sonic-port": {
4-
"sonic-port:PORT": {
5-
"PORT_LIST": [
6-
{
7-
"admin_status": "up",
8-
"alias": "eth0",
9-
"description": "Ethernet0",
10-
"lanes": 65,
11-
"mtu": 9000,
12-
"name": "Ethernet0",
13-
"speed": 25000
14-
}
15-
]
16-
}
17-
},
183
"sonic-events-swss:sonic-events-swss": {
194
"sonic-events-swss:if-state": {
205
"ifname": "Eth",
@@ -24,21 +9,6 @@
249
}
2510
},
2611
"SONIC_EVENTS_SWSS_IF_STATE_INCORRECT_STATUS": {
27-
"sonic-port:sonic-port": {
28-
"sonic-port:PORT": {
29-
"PORT_LIST": [
30-
{
31-
"admin_status": "up",
32-
"alias": "eth0",
33-
"description": "Ethernet0",
34-
"lanes": 65,
35-
"mtu": 9000,
36-
"name": "Ethernet0",
37-
"speed": 25000
38-
}
39-
]
40-
}
41-
},
4212
"sonic-events-swss:sonic-events-swss": {
4313
"sonic-events-swss:if-state": {
4414
"ifname": "Ethernet0",
@@ -48,21 +18,6 @@
4818
}
4919
},
5020
"SONIC_EVENTS_SWSS_IF_STATE_INCORRECT_TIMESTAMP": {
51-
"sonic-port:sonic-port": {
52-
"sonic-port:PORT": {
53-
"PORT_LIST": [
54-
{
55-
"admin_status": "up",
56-
"alias": "eth0",
57-
"description": "Ethernet0",
58-
"lanes": 65,
59-
"mtu": 9000,
60-
"name": "Ethernet0",
61-
"speed": 25000
62-
}
63-
]
64-
}
65-
},
6621
"sonic-events-swss:sonic-events-swss": {
6722
"sonic-events-swss:if-state": {
6823
"ifname": "Ethernet0",
@@ -72,21 +27,6 @@
7227
}
7328
},
7429
"SONIC_EVENTS_SWSS_IF_STATE_VALID": {
75-
"sonic-port:sonic-port": {
76-
"sonic-port:PORT": {
77-
"PORT_LIST": [
78-
{
79-
"admin_status": "up",
80-
"alias": "eth0",
81-
"description": "Ethernet0",
82-
"lanes": 65,
83-
"mtu": 9000,
84-
"name": "Ethernet0",
85-
"speed": 25000
86-
}
87-
]
88-
}
89-
},
9030
"sonic-events-swss:sonic-events-swss": {
9131
"sonic-events-swss:if-state": {
9232
"ifname": "Ethernet0",
@@ -96,21 +36,6 @@
9636
}
9737
},
9838
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_IFNAME": {
99-
"sonic-port:sonic-port": {
100-
"sonic-port:PORT": {
101-
"PORT_LIST": [
102-
{
103-
"admin_status": "up",
104-
"alias": "eth0",
105-
"description": "Ethernet0",
106-
"lanes": 65,
107-
"mtu": 9000,
108-
"name": "Ethernet0",
109-
"speed": 25000
110-
}
111-
]
112-
}
113-
},
11439
"sonic-events-swss:sonic-events-swss": {
11540
"sonic-events-swss:pfc-storm": {
11641
"ifname": "Eth",
@@ -122,21 +47,6 @@
12247
}
12348
},
12449
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_QUEUE_INDEX": {
125-
"sonic-port:sonic-port": {
126-
"sonic-port:PORT": {
127-
"PORT_LIST": [
128-
{
129-
"admin_status": "up",
130-
"alias": "eth0",
131-
"description": "Ethernet0",
132-
"lanes": 65,
133-
"mtu": 9000,
134-
"name": "Ethernet0",
135-
"speed": 25000
136-
}
137-
]
138-
}
139-
},
14050
"sonic-events-swss:sonic-events-swss": {
14151
"sonic-events-swss:pfc-storm": {
14252
"ifname": "Ethernet0",
@@ -148,21 +58,6 @@
14858
}
14959
},
15060
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_QUEUE_ID": {
151-
"sonic-port:sonic-port": {
152-
"sonic-port:PORT": {
153-
"PORT_LIST": [
154-
{
155-
"admin_status": "up",
156-
"alias": "eth0",
157-
"description": "Ethernet0",
158-
"lanes": 65,
159-
"mtu": 9000,
160-
"name": "Ethernet0",
161-
"speed": 25000
162-
}
163-
]
164-
}
165-
},
16661
"sonic-events-swss:sonic-events-swss": {
16762
"sonic-events-swss:pfc-storm": {
16863
"ifname": "Ethernet0",
@@ -174,21 +69,6 @@
17469
}
17570
},
17671
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_PORT_ID": {
177-
"sonic-port:sonic-port": {
178-
"sonic-port:PORT": {
179-
"PORT_LIST": [
180-
{
181-
"admin_status": "up",
182-
"alias": "eth0",
183-
"description": "Ethernet0",
184-
"lanes": 65,
185-
"mtu": 9000,
186-
"name": "Ethernet0",
187-
"speed": 25000
188-
}
189-
]
190-
}
191-
},
19272
"sonic-events-swss:sonic-events-swss": {
19373
"sonic-events-swss:pfc-storm": {
19474
"ifname": "Ethernet0",
@@ -200,21 +80,6 @@
20080
}
20181
},
20282
"SONIC_EVENTS_SWSS_PFC_STORM_INCORRECT_TIMESTAMP": {
203-
"sonic-port:sonic-port": {
204-
"sonic-port:PORT": {
205-
"PORT_LIST": [
206-
{
207-
"admin_status": "up",
208-
"alias": "eth0",
209-
"description": "Ethernet0",
210-
"lanes": 65,
211-
"mtu": 9000,
212-
"name": "Ethernet0",
213-
"speed": 25000
214-
}
215-
]
216-
}
217-
},
21883
"sonic-events-swss:sonic-events-swss": {
21984
"sonic-events-swss:pfc-storm": {
22085
"ifname": "Ethernet0",
@@ -226,21 +91,6 @@
22691
}
22792
},
22893
"SONIC_EVENTS_SWSS_PFC_STORM_VALID": {
229-
"sonic-port:sonic-port": {
230-
"sonic-port:PORT": {
231-
"PORT_LIST": [
232-
{
233-
"admin_status": "up",
234-
"alias": "eth0",
235-
"description": "Ethernet0",
236-
"lanes": 65,
237-
"mtu": 9000,
238-
"name": "Ethernet0",
239-
"speed": 25000
240-
}
241-
]
242-
}
243-
},
24494
"sonic-events-swss:sonic-events-swss": {
24595
"sonic-events-swss:pfc-storm": {
24696
"ifname": "Ethernet0",

src/sonic-yang-models/yang-models/sonic-events-dhcp-relay.yang

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ module sonic-events-dhcp-relay {
4040
name of the interface discarding.";
4141

4242
leaf ifname {
43-
type union {
44-
type leafref {
45-
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
46-
}
47-
type leafref {
48-
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
49-
}
43+
type string {
44+
pattern 'Ethernet[0-9]{1,3}';
5045
}
5146
description "Name of the i/f discarding";
52-
}
47+
}
5348

5449
uses evtcmn:sonic-events-cmn;
5550
}

src/sonic-yang-models/yang-models/sonic-events-swss.yang

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ module sonic-events-swss {
3838
The name of the flapping i/f and status are the only params.";
3939

4040
leaf ifname {
41-
type leafref {
42-
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
41+
type string {
42+
pattern 'Ethernet[0-9]{1,3}';
4343
}
4444
description "Interface name";
45-
}
45+
}
4646

4747
leaf status {
4848
type stypes:admin_status;
@@ -60,8 +60,8 @@ module sonic-events-swss {
6060
The name of the i/f facing the storm is the only param.";
6161

6262
leaf ifname {
63-
type leafref {
64-
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
63+
type string {
64+
pattern 'Ethernet[0-9]{1,2}';
6565
}
6666
description "Interface name";
6767
}

0 commit comments

Comments
 (0)