summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/vyos/ifconfig.py5
-rwxr-xr-xsrc/conf_mode/interface-loopback.py17
2 files changed, 9 insertions, 13 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 0cd27592a..944c1ef82 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -624,6 +624,11 @@ class Interface:
os.remove(self._dhcpv6_lease_file)
+class LoopbackIf(Interface):
+ def __init__(self, ifname=None):
+ super().__init__(ifname, type='loopback')
+
+
class DummyIf(Interface):
def __init__(self, ifname=None):
super().__init__(ifname, type='dummy')
diff --git a/src/conf_mode/interface-loopback.py b/src/conf_mode/interface-loopback.py
index 5c1419b11..1dd68c039 100755
--- a/src/conf_mode/interface-loopback.py
+++ b/src/conf_mode/interface-loopback.py
@@ -18,7 +18,7 @@
from os import environ
from sys import exit
from copy import deepcopy
-from pyroute2 import IPDB
+from vyos.ifconfig import LoopbackIf
from vyos.config import Config
from vyos import ConfigError
@@ -75,28 +75,19 @@ def generate(loopback):
return None
def apply(loopback):
- ipdb = IPDB(mode='explicit')
- lo_if = loopback['intf']
-
- # the loopback device always exists
- lo = ipdb.interfaces[lo_if]
- # begin() a transaction prior to make any change
- lo.begin()
-
+ lo = LoopbackIf(loopback['intf'])
if not loopback['deleted']:
# update interface description used e.g. within SNMP
# update interface description used e.g. within SNMP
lo.ifalias = loopback['description']
# configure interface address(es)
for addr in loopback['address']:
- lo.add_ip(addr)
+ lo.add_addr(addr)
# remove interface address(es)
for addr in loopback['address_remove']:
- lo.del_ip(addr)
+ lo.del_addr(addr)
- # commit changes on loopback interface
- lo.commit()
return None
if __name__ == '__main__':