-
Notifications
You must be signed in to change notification settings - Fork 52
[lldp] add lldpRemManAddrTable, lldpLocManAddrTable #8
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
Changes from 1 commit
7fcf58c
cac3f9a
4a61ab8
cb0da36
6fa90ab
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 |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| import subprocess | ||
| import re | ||
| from swsssdk import ConfigDBConnector | ||
|
|
||
| from sonic_syncd import SonicSyncDaemon | ||
| from . import logger | ||
|
|
||
| MGMT_INTERFACE_PATTERN = r"MGMT_INTERFACE*" | ||
| IPV4_PATTERN = r'^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$' | ||
|
|
||
|
|
||
| class DBSyncDaemon(SonicSyncDaemon): | ||
| """ | ||
|
|
@@ -17,6 +21,7 @@ def __init__(self): | |
| self.config_db.connect() | ||
| logger.info("[lldp dbsyncd] Connected to configdb") | ||
| self.port_table = {} | ||
| self.man_addr = None | ||
|
||
|
|
||
| def run_command(self, command): | ||
| p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) | ||
|
|
@@ -40,16 +45,36 @@ def port_handler(self, key, data): | |
| # update local cache | ||
| self.port_table[key] = data | ||
|
|
||
| def run(self): | ||
| def man_addr_init(self): | ||
|
||
|
|
||
| man_table = self.config_db.get_table('MGMT_INTERFACE') | ||
| # example table: | ||
| # {('eth0', 'FC00:2::32/64'): {'forced_mgmt_routes': ['10.0.0.100/31'], 'gwaddr': 'fc00:2::fe'}, | ||
| # ('eth0', '10.224.23.69/24'): {'gwaddr': '10.224.23.254'}} | ||
| mgmt_ips = [i[1].split('/')[0] for i in man_table.keys()] | ||
| ipv4_mgmt_ips = [i for i in mgmt_ips if re.match(IPV4_PATTERN, i)] | ||
| try: | ||
| self.run_command("lldpcli configure system ip management pattern {}" | ||
| .format(ipv4_mgmt_ips[0])) | ||
| logger.debug("Configured lldpd with {} local management ip".format(ipv4_mgmt_ips[0])) | ||
| except IndexError: | ||
| logger.error("No IPv4 management interface found") | ||
|
|
||
| def port_table_init(self): | ||
| self.port_table = self.config_db.get_table('PORT') | ||
| # supply LLDP_LOC_ENTRY_TABLE and lldpd with correct values on start | ||
| for port_name, attributes in self.port_table.items(): | ||
| self.run_command("lldpcli configure lldp portidsubtype local {} description '{}'" | ||
| .format(port_name, attributes.get("description", " "))) | ||
|
|
||
| def run(self): | ||
|
|
||
| self.port_table_init() | ||
|
Contributor
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. del the empty line? #Closed |
||
| # subscribe for further changes | ||
| self.config_db.subscribe('PORT', lambda table, key, data: | ||
| self.port_handler(key, data)) | ||
|
|
||
| self.man_addr_init() | ||
|
||
|
|
||
| logger.info("[lldp dbsyncd] Subscribed to configdb PORT table") | ||
| self.config_db.listen() | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
not used? #Closed