diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-19 22:20:46 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-19 22:22:24 +0200 |
commit | 6e21be23be126af259f07bb23e4893470b5cb2fb (patch) | |
tree | ce1068bd1cff18932c38d26dd0a4eeebab54e8d8 /python | |
parent | 0387cae19c28d1d5b8ccf45596841ba44a2eefc9 (diff) | |
download | vyos-1x-6e21be23be126af259f07bb23e4893470b5cb2fb.tar.gz vyos-1x-6e21be23be126af259f07bb23e4893470b5cb2fb.zip |
Python/ifconfig: T1666: re-activate physical interfaces on bond deletion
When a bond member gets deleted, all members are placed in A/D state even when
they are enabled in the CLI.
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/ifconfig.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 0793fad39..750a7cc70 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1057,6 +1057,36 @@ class BondIf(EthernetIf): def __init__(self, ifname): super().__init__(ifname, type='bond') + def remove(self): + """ + Remove interface from operating system. Removing the interface + deconfigures all assigned IP addresses and clear possible DHCP(v6) + client processes. + Example: + >>> from vyos.ifconfig import Interface + >>> i = Interface('eth0') + >>> i.remove() + """ + # when a bond member gets deleted, all members are placed in A/D state + # even when they are enabled inside CLI. This will make the config + # and system look async. + slave_list = [] + for s in self.get_slaves(): + slave = { + 'ifname' : s, + 'state': Interface(s).state + } + slave_list.append(slave) + + # remove bond master which places members in disabled state + super().remove() + + # replicate previous interface state before bond destruction back to + # physical interface + for slave in slave_list: + i = Interface(slave['ifname']) + i.state = slave['state'] + @property def xmit_hash_policy(self): """ |