From 475fbb785dca76868715827833dc44115635c4a6 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 4 Aug 2022 08:28:55 +0200 Subject: vyos.config.configdict: T4592: only print interface name, not interface dict on error --- python/vyos/configdict.py | 4 ++-- python/vyos/configverify.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'python/vyos') diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 20cc7de2a..8f822a97d 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -303,8 +303,8 @@ def is_source_interface(conf, interface, intftype=None): for it in intftype: base = ['interfaces', it] for intf in conf.list_nodes(base): - lower_intf = base + [intf, 'source-interface'] - if conf.exists(lower_intf) and interface in conf.return_values(lower_intf): + src_intf = base + [intf, 'source-interface'] + if conf.exists(src_intf) and interface in conf.return_values(src_intf): ret_val = intf break diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index ac56da204..2ab3cb408 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -284,15 +284,16 @@ def verify_source_interface(config): raise ConfigError('Specified source-interface {source_interface} does ' 'not exist'.format(**config)) + src_ifname = config['source_interface'] if 'source_interface_is_bridge_member' in config: - raise ConfigError('Invalid source-interface {source_interface}. Interface ' - 'is already a member of bridge ' - '{source_interface_is_bridge_member}'.format(**config)) + bridge_name = next(iter(config['source_interface_is_bridge_member'])) + raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface ' + f'is already a member of bridge "{bridge_name}"!') if 'source_interface_is_bond_member' in config: - raise ConfigError('Invalid source-interface {source_interface}. Interface ' - 'is already a member of bond ' - '{source_interface_is_bond_member}'.format(**config)) + bond_name = next(iter(config['source_interface_is_bond_member'])) + raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface ' + f'is already a member of bond "{bond_name}"!') def verify_dhcpv6(config): """ -- cgit v1.2.3