From c1993205d62033658b36e4ad4ad4bb62afc54ecc Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 23 Dec 2019 08:58:55 +0100 Subject: lldp: T1898: support multiple management addresses - management-address is not a node - added new vyos.validate.is_loopback_addr() function - returns true is address passed is a looback address --- src/conf_mode/lldp.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py index d8b8cb77e..51425aaaf 100755 --- a/src/conf_mode/lldp.py +++ b/src/conf_mode/lldp.py @@ -21,6 +21,7 @@ import jinja2 from copy import deepcopy from vyos.config import Config +from vyos.validate import is_addr_assigned,is_loopback_addr from vyos import ConfigError # Please be careful if you edit the template. @@ -40,8 +41,8 @@ configure system description "VyOS {{ options.description }}" {%- if listen_on -%} configure system interface pattern "{{ options.listen_on | join(",") }}" {%- endif %} -{% if options.addr -%} -configure system ip management pattern "{{ options.addr }}" +{% if options.mgmt_addr -%} +configure system ip management pattern {{ options.mgmt_addr | join(",") }} {%- endif %} {%- for loc in location -%} {%- if loc.elin %} @@ -66,7 +67,17 @@ def get_options(config): config.set_level('service lldp') options['listen_vlan'] = config.exists('listen-vlan') - options['addr'] = config.return_value('management-address') + options['mgmt_addr'] = [] + for addr in config.return_values('management-address'): + if is_addr_assigned(addr) and not is_loopback_addr(addr): + options['mgmt_addr'].append(addr) + else: + message = 'WARNING: LLDP management address {0} invalid - '.format(addr) + if is_loopback_addr(addr): + message += '(loopback address).' + else: + message += 'address not found.' + print(message) snmp = config.exists('snmp enable') options["snmp"] = snmp -- cgit v1.2.3