-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SONiC Yang model support for LLDP #7191
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"LLDP_GLOBAL_TEST": { | ||
"desc": "LLDP test global LLDP table" | ||
}, | ||
"LLDP_GLOBAL_TEST_INVALID_HELLO": { | ||
"desc": "LLDP test global table with invalid hello value", | ||
"eStrKey" : "InvalidValue", | ||
"eStr": ["hello_time"] | ||
}, | ||
"LLDP_GLOBAL_TEST_INVALID_MULTIPLIER": { | ||
"desc": "LLDP test global table with invalid multiplier value", | ||
"eStrKey" : "InvalidValue", | ||
"eStr": ["multiplier"] | ||
}, | ||
"LLDP_PORT_TEST": { | ||
"desc": "LLDP test LLDP port table" | ||
}, | ||
"LLDP_PORT_TEST_INVALID_IFNAME": { | ||
"desc": "LLDP test port table with invalid ifname", | ||
"eStrKey" : "LeafRef", | ||
"eStr": ["Eth"] | ||
}, | ||
"LLDP_PORT_TEST_INVALID_MODE": { | ||
"desc": "LLDP test port table with invalid mode", | ||
"eStrKey" : "InvalidValue", | ||
"eStr": ["mode"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
{ | ||
"LLDP_GLOBAL_TEST": { | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP": { | ||
"sonic-lldp:GLOBAL": { | ||
"mode": "TRANSMIT", | ||
"enabled": "true", | ||
"hello_time": "20", | ||
"multiplier": "5", | ||
"supp_mgmt_address_tlv": "true", | ||
"supp_system_capabilities_tlv": "false", | ||
"system_name": "sonic", | ||
"system_description": "sonic-system" | ||
} | ||
} | ||
} | ||
}, | ||
"LLDP_GLOBAL_TEST_INVALID_ID": { | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP": { | ||
"sonic-lldp:GLOBAL": { | ||
"mode": "TRANSMIT", | ||
"enabled": "true", | ||
"hello_time": "10", | ||
"multiplier": "5", | ||
"supp_mgmt_address_tlv": "true", | ||
"supp_system_capabilities_tlv": "false", | ||
"system_name": "sonic", | ||
"system_description": "sonic-system" | ||
} | ||
} | ||
} | ||
}, | ||
"LLDP_GLOBAL_TEST_INVALID_HELLO": { | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP": { | ||
"sonic-lldp:GLOBAL": { | ||
"mode": "TRANSMIT", | ||
"enabled": "true", | ||
"hello_time": "test", | ||
"multiplier": "5", | ||
"supp_mgmt_address_tlv": "true", | ||
"supp_system_capabilities_tlv": "false", | ||
"system_name": "sonic", | ||
"system_description": "sonic-system" | ||
} | ||
} | ||
} | ||
}, | ||
"LLDP_GLOBAL_TEST_INVALID_MULTIPLIER": { | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP": { | ||
"sonic-lldp:GLOBAL": { | ||
"mode": "TRANSMIT", | ||
"enabled": "true", | ||
"hello_time": "10", | ||
"multiplier": "xyz", | ||
"supp_mgmt_address_tlv": "true", | ||
"supp_system_capabilities_tlv": "false", | ||
"system_name": "sonic", | ||
"system_description": "sonic-system" | ||
} | ||
} | ||
} | ||
}, | ||
"LLDP_GLOBAL_TEST_DEFAULT_SUPP_MGMT_ADDR_TLV": { | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP": { | ||
"sonic-lldp:GLOBAL": { | ||
"mode": "TRANSMIT", | ||
"enabled": "true", | ||
"hello_time": "10", | ||
"multiplier": "5", | ||
"supp_mgmt_address_tlv": "false", | ||
"supp_system_capabilities_tlv": "false", | ||
"system_name": "sonic", | ||
"system_description": "sonic-system" | ||
} | ||
} | ||
} | ||
}, | ||
"LLDP_PORT_TEST": { | ||
"sonic-port:sonic-port": { | ||
"sonic-port:PORT": { | ||
"PORT_LIST": [ | ||
{ | ||
"admin_status": "up", | ||
"alias": "eth0", | ||
"description": "Ethernet0", | ||
"lanes": "65", | ||
"mtu": 9000, | ||
"name": "Ethernet0", | ||
"speed": 25000 | ||
} | ||
] | ||
} | ||
}, | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP_PORT": { | ||
"LLDP_PORT_LIST": [ | ||
{ | ||
"ifname": "Ethernet0", | ||
"mode": "TRANSMIT", | ||
"enabled": "true" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"LLDP_PORT_TEST_INVALID_IFNAME": { | ||
"sonic-port:sonic-port": { | ||
"sonic-port:PORT": { | ||
"PORT_LIST": [ | ||
{ | ||
"admin_status": "up", | ||
"alias": "eth0", | ||
"description": "Ethernet0", | ||
"lanes": "65", | ||
"mtu": 9000, | ||
"name": "Ethernet0", | ||
"speed": 25000 | ||
} | ||
] | ||
} | ||
}, | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP_PORT": { | ||
"LLDP_PORT_LIST": [ | ||
{ | ||
"ifname": "Eth", | ||
"mode": "TRANSMIT", | ||
"enabled": "true" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"LLDP_PORT_TEST_INVALID_MODE": { | ||
"sonic-port:sonic-port": { | ||
"sonic-port:PORT": { | ||
"PORT_LIST": [ | ||
{ | ||
"admin_status": "up", | ||
"alias": "eth0", | ||
"description": "Ethernet0", | ||
"lanes": "65", | ||
"mtu": 9000, | ||
"name": "Ethernet0", | ||
"speed": 25000 | ||
} | ||
] | ||
} | ||
}, | ||
"sonic-lldp:sonic-lldp": { | ||
"sonic-lldp:LLDP_PORT": { | ||
"LLDP_PORT_LIST": [ | ||
{ | ||
"ifname": "Ethernet0", | ||
"mode": "TRANSMITTING", | ||
"enabled": "true" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
module sonic-lldp { | ||
namespace "http://github.com/Azure/sonic-lldp"; | ||
prefix slldp; | ||
yang-version 1.1; | ||
|
||
import sonic-port { | ||
prefix prt; | ||
} | ||
|
||
import sonic-extension { | ||
prefix sonic-ext; | ||
} | ||
|
||
organization | ||
"SONiC"; | ||
|
||
contact | ||
"SONiC"; | ||
|
||
description | ||
"SONiC LLDP yang model"; | ||
|
||
revision 2020-04-16 { | ||
description | ||
"Initial revision."; | ||
} | ||
|
||
grouping lldp_mode_config { | ||
leaf enabled { | ||
type boolean; | ||
description | ||
"Enable/Disable LLDP"; | ||
} | ||
|
||
leaf mode { | ||
type enumeration { | ||
enum RECEIVE; | ||
enum TRANSMIT; | ||
} | ||
|
||
description | ||
"RX/TX mode for LLDP frames"; | ||
} | ||
} | ||
|
||
container sonic-lldp { | ||
container LLDP { | ||
container GLOBAL { | ||
|
||
leaf hello_time { | ||
type uint8 { | ||
range "5..254" { | ||
error-message "Invalid hello timer value."; | ||
} | ||
} | ||
default 30; | ||
units seconds; | ||
description | ||
"It is the time interval at which periodic hellos are | ||
exchanged. Default is 30 seconds"; | ||
} | ||
|
||
leaf multiplier { | ||
type uint8 { | ||
range "1..10" { | ||
error-message "Invalid LLDP multiplier value."; | ||
} | ||
} | ||
default 4; | ||
description | ||
"This multiplier value is used to determine the timeout | ||
interval (i.e. hello-time x multiplier value) after | ||
which LLDP neighbor entry is deleted."; | ||
} | ||
|
||
leaf system_name { | ||
type string; | ||
description | ||
"System administratively assigned name"; | ||
} | ||
|
||
leaf system_description { | ||
type string; | ||
description | ||
"System description"; | ||
} | ||
|
||
leaf supp_mgmt_address_tlv { | ||
type boolean; | ||
description | ||
"Suppress sending of Management Address TLV in LLDP frames"; | ||
} | ||
|
||
leaf supp_system_capabilities_tlv { | ||
type boolean; | ||
default false; | ||
description | ||
"Suppress sending of System Capabilities TLV in LLDP frames"; | ||
} | ||
|
||
leaf enabled { | ||
type boolean; | ||
default true; | ||
description | ||
"Enable/Disable LLDP"; | ||
} | ||
|
||
leaf mode { | ||
type enumeration { | ||
enum RECEIVE; | ||
enum TRANSMIT; | ||
} | ||
|
||
description | ||
"RX/TX mode for LLDP frames"; | ||
} | ||
|
||
//uses lldp_mode_config; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this from RFC 7950, can you plz point to the section. Thx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RFC7950 section - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for commenting "//uses lldp_mode_config;"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compilation fails with the usage of grouping (not related to this PR) hence its commented out, will uncomment once that issue is fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont see any outstanding issue on this, please mention the exact issue here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see below error when grouping is enabled - Using /sonic/src/sonic-yang-models/.eggs/ijson-2.6.1-py3.7-linux-x86_64.egg tests/test_sonic_yang_models.py .F [ 66%] =================================== FAILURES ===================================
E SystemExit: 1 tests/test_sonic_yang_models.py:30: SystemExit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems you need to re-base, this doesn't have the latest fix in this PYANG test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Post rebase seeing below issue - running build_ext tests/test_sonic_yang_mgmt.py . [ 3%] =================================== FAILURES =================================== self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:715: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>, xlateFile = None
sonic_yang_ext.py:432: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:420: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:376: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:340: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
E Exception: All Keys are not parsed in LLDP sonic_yang_ext.py:400: Exception During handling of the above exception, another exception occurred: self = <test_sonic_yang.Test_SonicYang object at 0x7fc63b710128>
tests/libyang-python-tests/test_sonic_yang.py:305: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
E sonic_yang_ext.SonicYangException: Data Loading Failed sonic_yang_ext.py:725: SonicYangException self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:715: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>, xlateFile = None
sonic_yang_ext.py:432: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:420: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:376: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
sonic_yang_ext.py:340: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
E Exception: All Keys are not parsed in LLDP sonic_yang_ext.py:400: Exception During handling of the above exception, another exception occurred: self = <test_sonic_yang.Test_SonicYang object at 0x7fc63b694da0>
tests/libyang-python-tests/test_sonic_yang.py:332: self = <sonic_yang.SonicYang object at 0x7fc63bb549b0>
E sonic_yang_ext.SonicYangException: Data Loading Failed sonic_yang_ext.py:725: SonicYangException There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @praveen-li @venkatmahalingam - can you please comment on the above failure? Also there was another issue (see below) which is mentioned in PR description, this was also discussed in yang subgroup, is this addressed or still pending - Compile sonic_yang_mgmt-1.0-py3-none-any.whl yang subgroup reference mail dated Apr 9, 2021, subject - sonic_yang_mgmt-1.0-py3-none-any.whl build error when use leaf with type boolean in sample_config_db.json |
||
} | ||
} | ||
|
||
container LLDP_PORT { | ||
list LLDP_PORT_LIST { | ||
key "ifname"; | ||
|
||
leaf ifname { | ||
type leafref { | ||
path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; | ||
} | ||
description | ||
"Reference of port on which LLDP to be configured."; | ||
} | ||
|
||
leaf enabled { | ||
type boolean; | ||
default true; | ||
description | ||
"Enable/Disable LLDP"; | ||
} | ||
|
||
leaf mode { | ||
type enumeration { | ||
enum RECEIVE; | ||
enum TRANSMIT; | ||
} | ||
|
||
description | ||
"RX/TX mode for LLDP frames"; | ||
} | ||
//uses lldp_mode_config; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the grouping "lldp_mode_config", any reason for this comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compilation fails with the usage of grouping (not related to this PR) hence its commented out, will uncomment once that issue is fixed. This was discussed in the PR review and the relevant information was also shared to yang sub-group over email. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please mention the exact issue. |
||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added tests