Fixing lldp issue displaying mac-addr instead of ports #1515
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current lldp.conf.j2 template demands the presence of MGMT_INTERFACE attribute in configDB, and by extension, also in config_db.json file. However, MGMT_INTERFACE configuration attribute is optional, so lldp shouldn't bail out if this one isn't provided in configuration.
For this reason, no lldp.conf file is ever created in lldp container in scenarios where MGMT_INTERFACE is not defined, and lldpd defaults to advertise the mac-address of the connected interface, instead of the interface name.
The fix is to simply relax this jinja2 statement to verify if MGMT_INTERFACE attribute is present.
<-- Before
root@lnos-x1-a-asw02:/# sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf
Traceback (most recent call last):
File "/usr/local/bin/sonic-cfggen", line 223, in
main()
File "/usr/local/bin/sonic-cfggen", line 204, in main
print template.render(data)
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line
1008,
in render return self.environment.handle_exception(exc_info, True)
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb)
File "/usr/share/sonic/templates/lldpd.conf.j2", line 1, in top-level template code
{% if MGMT_INTERFACE.keys() %}
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py",
line 430, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'MGMT_INTERFACE' is undefined
<-- After