From 3e108025a16a6d4db1bc08ea9161709b13295dfb Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:48:49 +0200 Subject: Python/ifconfig: T1557: loopback: implement derived remove() --- python/vyos/ifconfig.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python/vyos') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 86e2084d3..776fe1a23 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -680,6 +680,21 @@ class LoopbackIf(Interface): def __init__(self, ifname): super().__init__(ifname, type='loopback') + def remove(self): + """ + Loopback interface can not be deleted from operating system. We can + only remove all assigned IP addresses. + + Example: + >>> from vyos.ifconfig import Interface + >>> i = LoopbackIf('lo').remove() + """ + # remove all assigned IP addresses from interface + for addr in self.get_addr(): + self.del_addr(addr) + + # question: do we also delerte the loopback address? 127.0.0.1/8 + class DummyIf(Interface): -- cgit v1.2.3