Skip to content

Commit 5ce75ac

Browse files
[nvgre] Added YANG model and tests (sonic-net#9136)
- Why I did it NVGRE Tunnel feature extends the Config DB with new tables. These tables require a new YANG model. - How I did it Added a new YANG model sonic-nvgre-tunnel.yang - How to verify it Added YANG test cases. Signed-off-by: Vadym Hlushko <[email protected]>
1 parent fb752a4 commit 5ce75ac

File tree

5 files changed

+285
-2
lines changed

5 files changed

+285
-2
lines changed

src/sonic-yang-models/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def run(self):
108108
'./yang-models/sonic-mirror-session.yang',
109109
'./yang-models/sonic-ntp.yang',
110110
'./yang-models/sonic-nat.yang',
111+
'./yang-models/sonic-nvgre-tunnel.yang',
111112
'./yang-models/sonic-pbh.yang',
112113
'./yang-models/sonic-port.yang',
113114
'./yang-models/sonic-policer.yang',
@@ -165,6 +166,7 @@ def run(self):
165166
'./cvlyang-models/sonic-mgmt_vrf.yang',
166167
'./cvlyang-models/sonic-ntp.yang',
167168
'./cvlyang-models/sonic-nat.yang',
169+
'./cvlyang-models/sonic-nvgre-tunnel.yang',
168170
'./cvlyang-models/sonic-pbh.yang',
169171
'./cvlyang-models/sonic-policer.yang',
170172
'./cvlyang-models/sonic-port.yang',

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@
15401540
}
15411541
},
15421542

1543-
1543+
15441544
"MCLAG_DOMAIN": {
15451545
"123": {
15461546
"source_ip": "12.1.1.1",
@@ -1584,6 +1584,8 @@
15841584

15851585
}
15861586
},
1587+
1588+
15871589
"POLICER": {
15881590
"everflow_static_policer": {
15891591
"meter_type": "bytes",
@@ -1592,8 +1594,23 @@
15921594
"cbs": "12500000",
15931595
"color": "aware",
15941596
"red_packet_action": "drop"
1595-
}
1597+
}
1598+
},
1599+
1600+
1601+
"NVGRE_TUNNEL": {
1602+
"tunnel_1": {
1603+
"src_ip": "10.0.0.1"
1604+
}
1605+
},
1606+
"NVGRE_TUNNEL_MAP": {
1607+
"tunnel_1|Vlan111": {
1608+
"vlan_id": "111",
1609+
"vsid": "5000"
1610+
}
15961611
}
1612+
1613+
15971614
},
15981615
"SAMPLE_CONFIG_DB_UNKNOWN": {
15991616
"UNKNOWN_TABLE": {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"NVGRE_TUNNEL_AND_TUNNEL_MAP": {
3+
"desc": "NVGRE_TUNNEL with NVGRE_TUNNEL_MAP"
4+
},
5+
6+
"NVGRE_TUNNEL_INVALID_SRC_IP": {
7+
"desc": "INVALID src_ip value for NVGRE_TUNNEL",
8+
"eStrKey": "InvalidValue"
9+
},
10+
11+
"NVGRE_TUNNEL_MAP_UNEXISTING_NVGRE_TUNNEL_NAME": {
12+
"desc": "Unexisting NVGRE_TUNNEL",
13+
"eStrKey": "LeafRef"
14+
},
15+
16+
"NVGRE_TUNNEL_MAP_INVALID_VLAN_ID": {
17+
"desc": "Invalid VLAN ID",
18+
"eStrKey": "Pattern"
19+
},
20+
21+
"NVGRE_TUNNEL_MAP_INVALID_VSID": {
22+
"desc": "INVALID VSID value for NVGRE_TUNNEL_MAP",
23+
"eStrKey": "Pattern"
24+
}
25+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"NVGRE_TUNNEL_AND_TUNNEL_MAP": {
3+
"sonic-vlan:sonic-vlan": {
4+
"sonic-vlan:VLAN": {
5+
"VLAN_LIST": [
6+
{
7+
"name": "Vlan200"
8+
}
9+
]
10+
}
11+
},
12+
"sonic-nvgre-tunnel:sonic-nvgre-tunnel": {
13+
"sonic-nvgre-tunnel:NVGRE_TUNNEL": {
14+
"NVGRE_TUNNEL_LIST": [
15+
{
16+
"tunnel_name": "tunnel_1",
17+
"src_ip": "10.0.0.1"
18+
}
19+
]
20+
},
21+
"sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": {
22+
"NVGRE_TUNNEL_MAP_LIST": [
23+
{
24+
"tunnel_name": "tunnel_1",
25+
"tunnel_map_name": "Vlan200",
26+
"vlan_id": 200,
27+
"vsid": 5000
28+
}
29+
]
30+
}
31+
}
32+
},
33+
34+
"NVGRE_TUNNEL_INVALID_SRC_IP": {
35+
"sonic-nvgre-tunnel:sonic-nvgre-tunnel": {
36+
"sonic-nvgre-tunnel:NVGRE_TUNNEL": {
37+
"NVGRE_TUNNEL_LIST": [
38+
{
39+
"tunnel_name": "tunnel_1",
40+
"src_ip": "INVALID"
41+
}
42+
]
43+
}
44+
}
45+
},
46+
47+
"NVGRE_TUNNEL_MAP_UNEXISTING_NVGRE_TUNNEL_NAME": {
48+
"sonic-vlan:sonic-vlan": {
49+
"sonic-vlan:VLAN": {
50+
"VLAN_LIST": [
51+
{
52+
"name": "Vlan200"
53+
}
54+
]
55+
}
56+
},
57+
"sonic-nvgre-tunnel:sonic-nvgre-tunnel": {
58+
"sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": {
59+
"NVGRE_TUNNEL_MAP_LIST": [
60+
{
61+
"tunnel_name": "INVALID",
62+
"tunnel_map_name": "Vlan200",
63+
"vlan_id": 200,
64+
"vsid": 5000
65+
}
66+
]
67+
}
68+
}
69+
},
70+
71+
"NVGRE_TUNNEL_MAP_INVALID_VLAN_ID": {
72+
"sonic-nvgre-tunnel:sonic-nvgre-tunnel": {
73+
"sonic-nvgre-tunnel:NVGRE_TUNNEL": {
74+
"NVGRE_TUNNEL_LIST": [
75+
{
76+
"tunnel_name": "tunnel_1",
77+
"src_ip": "10.0.0.1"
78+
}
79+
]
80+
},
81+
"sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": {
82+
"NVGRE_TUNNEL_MAP_LIST": [
83+
{
84+
"tunnel_name": "tunnel_1",
85+
"tunnel_map_name": "Vlan200",
86+
"vlan_id": 5000,
87+
"vsid": 5000
88+
}
89+
]
90+
}
91+
}
92+
},
93+
94+
"NVGRE_TUNNEL_MAP_INVALID_VSID": {
95+
"sonic-vlan:sonic-vlan": {
96+
"sonic-vlan:VLAN": {
97+
"VLAN_LIST": [
98+
{
99+
"name": "Vlan200"
100+
}
101+
]
102+
}
103+
},
104+
"sonic-nvgre-tunnel:sonic-nvgre-tunnel": {
105+
"sonic-nvgre-tunnel:NVGRE_TUNNEL": {
106+
"NVGRE_TUNNEL_LIST": [
107+
{
108+
"tunnel_name": "tunnel_1",
109+
"src_ip": "10.0.0.1"
110+
}
111+
]
112+
},
113+
"sonic-nvgre-tunnel:NVGRE_TUNNEL_MAP": {
114+
"NVGRE_TUNNEL_MAP_LIST": [
115+
{
116+
"tunnel_name": "tunnel_1",
117+
"tunnel_map_name": "Vlan200",
118+
"vlan_id": 200,
119+
"vsid": 999999999
120+
}
121+
]
122+
}
123+
}
124+
}
125+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
module sonic-nvgre-tunnel {
2+
3+
yang-version 1.1;
4+
5+
namespace "http://github.com/Azure/sonic-nvgre-tunnel";
6+
prefix nvgre;
7+
8+
import ietf-inet-types {
9+
prefix inet;
10+
}
11+
12+
import sonic-vlan {
13+
prefix vlan;
14+
}
15+
16+
17+
organization
18+
"SONiC";
19+
20+
contact
21+
"SONiC";
22+
23+
description
24+
"NVGRE Tunnel YANG Module for SONiC OS";
25+
26+
revision 2021-10-31 {
27+
description
28+
"First Revision";
29+
}
30+
31+
container sonic-nvgre-tunnel {
32+
33+
container NVGRE_TUNNEL {
34+
35+
description "NVGRE_TUNNEL part of config_db.json";
36+
37+
list NVGRE_TUNNEL_LIST {
38+
39+
key "tunnel_name";
40+
41+
leaf tunnel_name {
42+
description "NVGRE Tunnel name";
43+
44+
type string {
45+
length 1..255;
46+
}
47+
}
48+
49+
leaf src_ip {
50+
description "Source IP address";
51+
52+
mandatory true;
53+
type inet:ip-address;
54+
}
55+
56+
}
57+
/* end of NVGRE_TUNNEL_LIST */
58+
59+
}
60+
/* end of container NVGRE_TUNNEL */
61+
62+
container NVGRE_TUNNEL_MAP {
63+
64+
description "NVGRE_TUNNEL_MAP part of config_db.json";
65+
66+
list NVGRE_TUNNEL_MAP_LIST {
67+
68+
key "tunnel_name tunnel_map_name";
69+
70+
leaf tunnel_name {
71+
description "NVGRE Tunnel name";
72+
73+
type leafref {
74+
path /nvgre:sonic-nvgre-tunnel/nvgre:NVGRE_TUNNEL/nvgre:NVGRE_TUNNEL_LIST/nvgre:tunnel_name;
75+
}
76+
}
77+
78+
leaf tunnel_map_name {
79+
description "NVGRE Tunnel map name";
80+
81+
type string {
82+
length 1..255;
83+
}
84+
}
85+
86+
leaf vlan_id {
87+
description "VLAN identifier";
88+
89+
mandatory true;
90+
type uint16 {
91+
range 1..4094;
92+
}
93+
}
94+
95+
leaf vsid {
96+
description "Virtual Subnet Identifier";
97+
98+
mandatory true;
99+
type uint32 {
100+
range 0..16777214;
101+
}
102+
}
103+
104+
}
105+
/* end of NVGRE_TUNNEL_MAP_LIST */
106+
107+
}
108+
/* end of container NVGRE_TUNNEL_MAP */
109+
110+
}
111+
/* end of container sonic-nvgre-tunnel */
112+
113+
}
114+
/* end of module sonic-nvgre-tunnel */

0 commit comments

Comments
 (0)