diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-12-22 19:48:54 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-12-22 19:48:54 +0100 |
commit | 6aca7f73449ea79d4899ca34f0ae17e9c6aaeaab (patch) | |
tree | 95d522684e8a5fd4b9194bc4c894a4b964cf7226 /src/conf_mode/lldp.py | |
parent | 2cac6f3ce09ddb5140e364e86476feba4a8ed285 (diff) | |
download | vyos-1x-6aca7f73449ea79d4899ca34f0ae17e9c6aaeaab.tar.gz vyos-1x-6aca7f73449ea79d4899ca34f0ae17e9c6aaeaab.zip |
lldp: T393: support listen interfaces
Diffstat (limited to 'src/conf_mode/lldp.py')
-rwxr-xr-x | src/conf_mode/lldp.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py index 16bb329c4..62bb6a52e 100755 --- a/src/conf_mode/lldp.py +++ b/src/conf_mode/lldp.py @@ -37,6 +37,9 @@ vyos_tmpl = """ configure system platform VyOS configure system description "VyOS {{ description }}" +{% if listen_on %} +configure system interface pattern "{{ listen_on | join(",") }}" +{% endif %} """ @@ -66,6 +69,10 @@ def get_options(config): options['fdp'] = config.exists('fdp') options['sonmp'] = config.exists('sonmp') + # start with an unknown version information + options['description'] = 'unknown' + options['listen_on'] = [] + return options def get_interface_list(config): @@ -243,18 +250,28 @@ def generate(lldp): if lldp is None: return - version = 'unknown' with open('/opt/vyatta/etc/version', 'r') as f: tmp = f.read() - version = tmp.split()[1] + lldp['options']['description'] = tmp.split()[1] + + + # generate listen on interfaces + for intf in lldp['interface_list']: + tmp = '' + # add exclamation mark if interface is disabled + if intf['disable']: + tmp = '!' - lldp['options']['description'] = version + tmp += intf['name'] + lldp['options']['listen_on'].append(tmp) + # generate /etc/default/lldpd tmpl = jinja2.Template(lldp_tmpl) config_text = tmpl.render(lldp['options']) with open(config_file, 'w') as f: f.write(config_text) + # generate /etc/lldpd.d/01-vyos.conf tmpl = jinja2.Template(vyos_tmpl) config_text = tmpl.render(lldp['options']) with open(vyos_config_file, 'w') as f: |