diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-08-31 13:08:14 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-08-31 13:08:14 +0200 |
commit | 3dc08ceaf2c9574133f3b4ff94822b65789a2139 (patch) | |
tree | 2c82c269678dfeaa10de69455a80c9f4ffd803e3 /src | |
parent | 04b192c7d1949a6c8223051f144287ac8dbbd1ec (diff) | |
download | vyos-1x-3dc08ceaf2c9574133f3b4ff94822b65789a2139.tar.gz vyos-1x-3dc08ceaf2c9574133f3b4ff94822b65789a2139.zip |
dummy: T1580: migrate from pyroute2 -> vyos.ifconfig
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/interface-dummy.py | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/conf_mode/interface-dummy.py b/src/conf_mode/interface-dummy.py index d8a36a5b2..1f76d0638 100755 --- a/src/conf_mode/interface-dummy.py +++ b/src/conf_mode/interface-dummy.py @@ -19,8 +19,8 @@ from os import environ from copy import deepcopy from sys import exit -from pyroute2 import IPDB from vyos.config import Config +from vyos.ifconfig import DummyIf from vyos import ConfigError default_config_data = { @@ -83,45 +83,26 @@ def generate(dummy): return None def apply(dummy): - ipdb = IPDB(mode='explicit') - dummyif = dummy['intf'] + du = DummyIf(dummy['intf']) # Remove dummy interface if dummy['deleted']: - try: - # delete dummy interface - with ipdb.interface[ dummyif ] as du: - du.remove() - except: - pass + du.remove() else: - try: - # create dummy interface if it's non existing - ipdb.create(kind='dummy', ifname=dummyif).commit() - except: - pass - - # retrieve handle to dummy interface - du = ipdb.interfaces[dummyif] - # begin a transaction prior to make any change - du.begin() # enable interface - du.up() + du.state = 'up' # update interface description used e.g. within SNMP du.ifalias = dummy['description'] # Configure interface address(es) for addr in dummy['address_remove']: - du.del_ip(addr) + du.del_addr(addr) for addr in dummy['address']: - du.add_ip(addr) + du.add_addr(addr) # disable interface on demand if dummy['disable']: - du.down() - - # commit changes on bridge interface - du.commit() + du.state = 'down' return None |