summaryrefslogtreecommitdiff
path: root/src/conf_mode/interface-dummy.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-04 21:50:04 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-04 22:03:10 +0200
commit64d58eda4c1ebaa9d346d65d606d2a75694467ee (patch)
tree4f4c9b9720da401863c664a87e68ceda6a645377 /src/conf_mode/interface-dummy.py
parentff34756f534bfc0f09a5ab6db0d36e1bf43546a8 (diff)
downloadvyos-1x-64d58eda4c1ebaa9d346d65d606d2a75694467ee.tar.gz
vyos-1x-64d58eda4c1ebaa9d346d65d606d2a75694467ee.zip
Python/configdict: add list_diff function to compare two lists
A list containing only unique elements not part of the other list is returned. This is usefull to check e.g. which IP addresses need to be removed from the OS.
Diffstat (limited to 'src/conf_mode/interface-dummy.py')
-rwxr-xr-xsrc/conf_mode/interface-dummy.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/conf_mode/interface-dummy.py b/src/conf_mode/interface-dummy.py
index 03afdc668..4a1179672 100755
--- a/src/conf_mode/interface-dummy.py
+++ b/src/conf_mode/interface-dummy.py
@@ -19,8 +19,10 @@
from os import environ
from copy import deepcopy
from sys import exit
-from vyos.config import Config
+
from vyos.ifconfig import DummyIf
+from vyos.configdict import list_diff
+from vyos.config import Config
from vyos import ConfigError
default_config_data = {
@@ -32,10 +34,6 @@ default_config_data = {
'intf': ''
}
-def diff(first, second):
- second = set(second)
- return [item for item in first if item not in second]
-
def get_config():
dummy = deepcopy(default_config_data)
conf = Config()
@@ -70,7 +68,7 @@ def get_config():
# address is no longer valid and needs to be removed from the interface
eff_addr = conf.return_effective_values('address')
act_addr = conf.return_values('address')
- dummy['address_remove'] = diff(eff_addr, act_addr)
+ dummy['address_remove'] = list_diff(eff_addr, act_addr)
return dummy