summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-31 13:08:45 +0200
committerChristian Poessinger <christian@poessinger.com>2019-08-31 13:08:45 +0200
commite461fcf77c8b071a26e5c57021890bb96ccb7504 (patch)
tree11d9a67364efe41c7a7686b81ac4bb6b699e0f3e
parent3dc08ceaf2c9574133f3b4ff94822b65789a2139 (diff)
downloadvyos-1x-e461fcf77c8b071a26e5c57021890bb96ccb7504.tar.gz
vyos-1x-e461fcf77c8b071a26e5c57021890bb96ccb7504.zip
loopback: T1601: migrate from pyroute2 -> vyos.ifconfig
-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__':