summaryrefslogtreecommitdiff
path: root/src/conf_mode/interface-loopback.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-31 13:13:15 +0200
committerGitHub <noreply@github.com>2019-08-31 13:13:15 +0200
commit153c60d65d9cbb15e2d071dfecbb4d9994dd77ec (patch)
tree1831ccaf4b28ac1d7dccbc6b307edb22c25e16a3 /src/conf_mode/interface-loopback.py
parent5348c46c0eb5e1a2f2d059695ba971c211c0f260 (diff)
parentbfb2b883071b27adbb33035ae51caf69fc338972 (diff)
downloadvyos-1x-153c60d65d9cbb15e2d071dfecbb4d9994dd77ec.tar.gz
vyos-1x-153c60d65d9cbb15e2d071dfecbb4d9994dd77ec.zip
Merge pull request #121 from c-po/t1557-ifconfig
T1557 Create generic abstraction for configuring interfaces e.g. IP address
Diffstat (limited to 'src/conf_mode/interface-loopback.py')
-rwxr-xr-xsrc/conf_mode/interface-loopback.py17
1 files changed, 4 insertions, 13 deletions
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__':