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:42:54 +0100 |
commit | 7ecfd10b3eb915968203ec4ca795f8ca499aac6a (patch) | |
tree | dde0f0b3070023c4c1b02cfa8ec841dd9dd56b4c /src/conf_mode | |
parent | 49ee763a1892b011213446f5ccb12b53fbbd1622 (diff) | |
download | vyos-1x-7ecfd10b3eb915968203ec4ca795f8ca499aac6a.tar.gz vyos-1x-7ecfd10b3eb915968203ec4ca795f8ca499aac6a.zip |
igmp-proxy: T1893: verify that proxy interface exists
(cherry picked from commit 033205eb58acda9f571fbb5e84374a29186837e6)
Diffstat (limited to 'src/conf_mode')
-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 |