diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-12-19 23:00:13 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-12-20 14:41:17 +0100 |
commit | 033205eb58acda9f571fbb5e84374a29186837e6 (patch) | |
tree | b9c4596a127d902657683f262ba40d6129c60e5b | |
parent | 9a0f6371be5ef97974a4cc6d8f4fb97c3f9741ac (diff) | |
download | vyos-1x-033205eb58acda9f571fbb5e84374a29186837e6.tar.gz vyos-1x-033205eb58acda9f571fbb5e84374a29186837e6.zip |
igmp-proxy: T1893: verify that proxy interface exists
-rwxr-xr-x | src/conf_mode/igmp_proxy.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/conf_mode/igmp_proxy.py b/src/conf_mode/igmp_proxy.py index 37744535e..cd0704124 100755 --- a/src/conf_mode/igmp_proxy.py +++ b/src/conf_mode/igmp_proxy.py @@ -20,6 +20,7 @@ import sys import os import jinja2 +from netifaces import interfaces from vyos.config import Config from vyos import ConfigError @@ -51,11 +52,11 @@ quickleave {% endif -%} {% for interface in interfaces %} -# Configuration for {{ interface.interface }} ({{ interface.role }} interface) +# Configuration for {{ interface.name }} ({{ interface.role }} interface) {% if interface.role == 'disabled' -%} -phyint {{ interface.interface }} disabled +phyint {{ interface.name }} disabled {%- else -%} -phyint {{ interface.interface }} {{ interface.role }} ratelimit 0 threshold {{ interface.threshold }} +phyint {{ interface.name }} {{ interface.role }} ratelimit 0 threshold {{ interface.threshold }} {%- endif -%} {%- for subnet in interface.alt_subnet %} altnet {{ subnet }} @@ -91,7 +92,7 @@ def get_config(): for intf in conf.list_nodes('interface'): conf.set_level('protocols igmp-proxy interface {0}'.format(intf)) interface = { - 'interface': intf, + 'name': intf, 'alt_subnet': [], 'role': 'downstream', 'threshold': '1', @@ -130,6 +131,8 @@ def verify(igmp_proxy): upstream = 0 for interface in igmp_proxy['interfaces']: + if interface['name'] not in interfaces(): + raise ConfigError('Interface "{}" does not exist'.format(interface['name'])) if "upstream" == interface['role']: upstream += 1 |