summaryrefslogtreecommitdiff
path: root/src/conf_mode/lldp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-23 08:58:55 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-23 08:58:55 +0100
commitc1993205d62033658b36e4ad4ad4bb62afc54ecc (patch)
tree7f5af03c2cf023d1261a9143e102c7d540f3e875 /src/conf_mode/lldp.py
parent81f67ca2bcf016ca7a0e021016d8945fc2e11002 (diff)
downloadvyos-1x-c1993205d62033658b36e4ad4ad4bb62afc54ecc.tar.gz
vyos-1x-c1993205d62033658b36e4ad4ad4bb62afc54ecc.zip
lldp: T1898: support multiple management addresses
- management-address is not a <multi/> node - added new vyos.validate.is_loopback_addr() function - returns true is address passed is a looback address
Diffstat (limited to 'src/conf_mode/lldp.py')
-rwxr-xr-xsrc/conf_mode/lldp.py17
1 files changed, 14 insertions, 3 deletions
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