diff options
author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-05-03 21:01:50 +0200 |
---|---|---|
committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-05-04 22:59:39 +0200 |
commit | d3ac208e936caa172c575c953d3e8582286f70ef (patch) | |
tree | 11fabb9757d820a73ba3d03abb9d5fc089a592a6 /src/conf_mode | |
parent | 1c93e3895787641a207d09c562f2703fddc77b8f (diff) | |
download | vyos-1x-d3ac208e936caa172c575c953d3e8582286f70ef.tar.gz vyos-1x-d3ac208e936caa172c575c953d3e8582286f70ef.zip |
bonding: T2241: disallow adding interfaces with addresses to bond
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/interfaces-bonding.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index 7681a8c71..ec9e0bb11 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -25,6 +25,7 @@ from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config from vyos.configdict import list_diff, intf_to_dict, add_to_dict from vyos.config import Config from vyos.util import call, cmd +from vyos.validate import has_address_configured from vyos import ConfigError default_config_data = { @@ -213,9 +214,10 @@ def verify(bond): 'belongs to {}'.format(intf, tmp)) # can not add interfaces with an assigned address to a bond - if conf.exists('interfaces ethernet ' + intf + ' address'): - raise ConfigError('can not enslave interface {} which has an address ' \ - 'assigned'.format(intf)) + if has_address_configured(conf, intf): + raise ConfigError(( + f'Cannot add interface "{intf}" to bond "{bond["intf"]}", ' + f'it has an address assigned!')) # bond members are not allowed to be bridge members, too for tmp in conf.list_nodes('interfaces bridge'): |