Skip to content

Commit 92d4bfe

Browse files
authored
[yang]: SONiC Yang model support for LLDP (#8120)
1 parent 48da159 commit 92d4bfe

File tree

5 files changed

+368
-0
lines changed

5 files changed

+368
-0
lines changed

src/sonic-yang-models/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
'./yang-models/sonic-versions.yang',
7373
'./yang-models/sonic-vlan.yang',
7474
'./yang-models/sonic-vrf.yang',
75+
'./yang-models/sonic-lldp.yang',
7576
'./yang-models/sonic_yang_tree']),
7677
],
7778
zip_safe=False,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,24 @@
10501050
"trap_ids": "ip2me",
10511051
"trap_group": "queue1_group1"
10521052
}
1053+
},
1054+
"LLDP": {
1055+
"GLOBAL": {
1056+
"mode": "TRANSMIT",
1057+
"enabled": "true",
1058+
"hello_time": "12",
1059+
"multiplier": "5",
1060+
"supp_mgmt_address_tlv": "true",
1061+
"supp_system_capabilities_tlv": "false",
1062+
"system_name": "sonic",
1063+
"system_description": "sonic-system"
1064+
}
1065+
},
1066+
"LLDP_PORT": {
1067+
"Ethernet0": {
1068+
"mode": "TRANSMIT",
1069+
"enabled": "true"
1070+
}
10531071
}
10541072

10551073
},
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"LLDP_GLOBAL_TEST": {
3+
"desc": "LLDP test global LLDP table"
4+
},
5+
"LLDP_GLOBAL_TEST_INVALID_HELLO": {
6+
"desc": "LLDP test global table with invalid hello value",
7+
"eStrKey" : "InvalidValue",
8+
"eStr": ["hello_time"]
9+
},
10+
"LLDP_GLOBAL_TEST_INVALID_MULTIPLIER": {
11+
"desc": "LLDP test global table with invalid multiplier value",
12+
"eStrKey" : "InvalidValue",
13+
"eStr": ["multiplier"]
14+
},
15+
"LLDP_PORT_TEST": {
16+
"desc": "LLDP test LLDP port table"
17+
},
18+
"LLDP_PORT_TEST_INVALID_IFNAME": {
19+
"desc": "LLDP test port table with invalid ifname",
20+
"eStrKey" : "LeafRef",
21+
"eStr": ["Eth"]
22+
},
23+
"LLDP_PORT_TEST_INVALID_MODE": {
24+
"desc": "LLDP test port table with invalid mode",
25+
"eStrKey" : "InvalidValue",
26+
"eStr": ["mode"]
27+
}
28+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
{
2+
"LLDP_GLOBAL_TEST": {
3+
"sonic-lldp:sonic-lldp": {
4+
"sonic-lldp:LLDP": {
5+
"sonic-lldp:GLOBAL": {
6+
"mode": "TRANSMIT",
7+
"enabled": "true",
8+
"hello_time": "20",
9+
"multiplier": "5",
10+
"supp_mgmt_address_tlv": "true",
11+
"supp_system_capabilities_tlv": "false",
12+
"system_name": "sonic",
13+
"system_description": "sonic-system"
14+
}
15+
}
16+
}
17+
},
18+
"LLDP_GLOBAL_TEST_INVALID_ID": {
19+
"sonic-lldp:sonic-lldp": {
20+
"sonic-lldp:LLDP": {
21+
"sonic-lldp:GLOBAL": {
22+
"mode": "TRANSMIT",
23+
"enabled": "true",
24+
"hello_time": "10",
25+
"multiplier": "5",
26+
"supp_mgmt_address_tlv": "true",
27+
"supp_system_capabilities_tlv": "false",
28+
"system_name": "sonic",
29+
"system_description": "sonic-system"
30+
}
31+
}
32+
}
33+
},
34+
"LLDP_GLOBAL_TEST_INVALID_HELLO": {
35+
"sonic-lldp:sonic-lldp": {
36+
"sonic-lldp:LLDP": {
37+
"sonic-lldp:GLOBAL": {
38+
"mode": "TRANSMIT",
39+
"enabled": "true",
40+
"hello_time": "test",
41+
"multiplier": "5",
42+
"supp_mgmt_address_tlv": "true",
43+
"supp_system_capabilities_tlv": "false",
44+
"system_name": "sonic",
45+
"system_description": "sonic-system"
46+
}
47+
}
48+
}
49+
},
50+
"LLDP_GLOBAL_TEST_INVALID_MULTIPLIER": {
51+
"sonic-lldp:sonic-lldp": {
52+
"sonic-lldp:LLDP": {
53+
"sonic-lldp:GLOBAL": {
54+
"mode": "TRANSMIT",
55+
"enabled": "true",
56+
"hello_time": "10",
57+
"multiplier": "xyz",
58+
"supp_mgmt_address_tlv": "true",
59+
"supp_system_capabilities_tlv": "false",
60+
"system_name": "sonic",
61+
"system_description": "sonic-system"
62+
}
63+
}
64+
}
65+
},
66+
"LLDP_GLOBAL_TEST_DEFAULT_SUPP_MGMT_ADDR_TLV": {
67+
"sonic-lldp:sonic-lldp": {
68+
"sonic-lldp:LLDP": {
69+
"sonic-lldp:GLOBAL": {
70+
"mode": "TRANSMIT",
71+
"enabled": "true",
72+
"hello_time": "10",
73+
"multiplier": "5",
74+
"supp_mgmt_address_tlv": "false",
75+
"supp_system_capabilities_tlv": "false",
76+
"system_name": "sonic",
77+
"system_description": "sonic-system"
78+
}
79+
}
80+
}
81+
},
82+
"LLDP_PORT_TEST": {
83+
"sonic-port:sonic-port": {
84+
"sonic-port:PORT": {
85+
"PORT_LIST": [
86+
{
87+
"admin_status": "up",
88+
"alias": "eth0",
89+
"description": "Ethernet0",
90+
"lanes": "65",
91+
"mtu": 9000,
92+
"name": "Ethernet0",
93+
"speed": 25000
94+
}
95+
]
96+
}
97+
},
98+
"sonic-lldp:sonic-lldp": {
99+
"sonic-lldp:LLDP_PORT": {
100+
"LLDP_PORT_LIST": [
101+
{
102+
"ifname": "Ethernet0",
103+
"mode": "TRANSMIT",
104+
"enabled": "true"
105+
}
106+
]
107+
}
108+
}
109+
},
110+
"LLDP_PORT_TEST_INVALID_IFNAME": {
111+
"sonic-port:sonic-port": {
112+
"sonic-port:PORT": {
113+
"PORT_LIST": [
114+
{
115+
"admin_status": "up",
116+
"alias": "eth0",
117+
"description": "Ethernet0",
118+
"lanes": "65",
119+
"mtu": 9000,
120+
"name": "Ethernet0",
121+
"speed": 25000
122+
}
123+
]
124+
}
125+
},
126+
"sonic-lldp:sonic-lldp": {
127+
"sonic-lldp:LLDP_PORT": {
128+
"LLDP_PORT_LIST": [
129+
{
130+
"ifname": "Eth",
131+
"mode": "TRANSMIT",
132+
"enabled": "true"
133+
}
134+
]
135+
}
136+
}
137+
},
138+
"LLDP_PORT_TEST_INVALID_MODE": {
139+
"sonic-port:sonic-port": {
140+
"sonic-port:PORT": {
141+
"PORT_LIST": [
142+
{
143+
"admin_status": "up",
144+
"alias": "eth0",
145+
"description": "Ethernet0",
146+
"lanes": "65",
147+
"mtu": 9000,
148+
"name": "Ethernet0",
149+
"speed": 25000
150+
}
151+
]
152+
}
153+
},
154+
"sonic-lldp:sonic-lldp": {
155+
"sonic-lldp:LLDP_PORT": {
156+
"LLDP_PORT_LIST": [
157+
{
158+
"ifname": "Ethernet0",
159+
"mode": "TRANSMITTING",
160+
"enabled": "true"
161+
}
162+
]
163+
}
164+
}
165+
}
166+
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
module sonic-lldp {
2+
namespace "http://github.com/Azure/sonic-lldp";
3+
prefix slldp;
4+
yang-version 1.1;
5+
6+
import sonic-port {
7+
prefix prt;
8+
}
9+
10+
import sonic-extension {
11+
prefix sonic-ext;
12+
}
13+
14+
organization
15+
"SONiC";
16+
17+
contact
18+
"SONiC";
19+
20+
description
21+
"SONiC LLDP yang model";
22+
23+
revision 2021-07-08 {
24+
description
25+
"Initial revision.";
26+
}
27+
28+
grouping lldp_mode_config {
29+
leaf enabled {
30+
type boolean;
31+
description
32+
"Enable/Disable LLDP";
33+
}
34+
35+
leaf mode {
36+
type enumeration {
37+
enum RECEIVE;
38+
enum TRANSMIT;
39+
}
40+
41+
description
42+
"RX/TX mode for LLDP frames";
43+
}
44+
}
45+
46+
container sonic-lldp {
47+
container LLDP {
48+
container GLOBAL {
49+
50+
leaf hello_time {
51+
type uint8 {
52+
range "5..254" {
53+
error-message "Invalid hello timer value.";
54+
}
55+
}
56+
default 30;
57+
units seconds;
58+
description
59+
"It is the time interval at which periodic hellos are
60+
exchanged. Default is 30 seconds";
61+
}
62+
63+
leaf multiplier {
64+
type uint8 {
65+
range "1..10" {
66+
error-message "Invalid LLDP multiplier value.";
67+
}
68+
}
69+
default 4;
70+
description
71+
"This multiplier value is used to determine the timeout
72+
interval (i.e. hello-time x multiplier value) after
73+
which LLDP neighbor entry is deleted.";
74+
}
75+
76+
leaf system_name {
77+
type string;
78+
description
79+
"System administratively assigned name";
80+
}
81+
82+
leaf system_description {
83+
type string;
84+
description
85+
"System description";
86+
}
87+
88+
leaf supp_mgmt_address_tlv {
89+
type boolean;
90+
default false;
91+
description
92+
"Suppress sending of Management Address TLV in LLDP frames";
93+
}
94+
95+
leaf supp_system_capabilities_tlv {
96+
type boolean;
97+
default false;
98+
description
99+
"Suppress sending of System Capabilities TLV in LLDP frames";
100+
}
101+
102+
leaf enabled {
103+
type boolean;
104+
default true;
105+
description
106+
"Enable/Disable LLDP";
107+
}
108+
109+
leaf mode {
110+
type enumeration {
111+
enum RECEIVE;
112+
enum TRANSMIT;
113+
}
114+
115+
description
116+
"RX/TX mode for LLDP frames";
117+
}
118+
119+
//uses lldp_mode_config;
120+
}
121+
}
122+
123+
container LLDP_PORT {
124+
list LLDP_PORT_LIST {
125+
key "ifname";
126+
127+
leaf ifname {
128+
type leafref {
129+
path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name";
130+
}
131+
description
132+
"Reference of port on which LLDP to be configured.";
133+
}
134+
135+
leaf enabled {
136+
type boolean;
137+
default true;
138+
description
139+
"Enable/Disable LLDP";
140+
}
141+
142+
leaf mode {
143+
type enumeration {
144+
enum RECEIVE;
145+
enum TRANSMIT;
146+
}
147+
148+
description
149+
"RX/TX mode for LLDP frames";
150+
}
151+
//uses lldp_mode_config;
152+
}
153+
}
154+
}
155+
}

0 commit comments

Comments
 (0)