summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_interfaces_erspan.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-02-28 10:50:06 +0100
committerChristian Poessinger <christian@poessinger.com>2021-02-28 18:10:08 +0100
commitf13cc56d665a91ff3fac47df260301afefb1a3a5 (patch)
treefbf18680d85364b2b6e2964604aa37e85299c767 /smoketest/scripts/cli/test_interfaces_erspan.py
parent458e71dd7b1af3354a7643a0d26e651a9e7ccfcf (diff)
downloadvyos-1x-f13cc56d665a91ff3fac47df260301afefb1a3a5.tar.gz
vyos-1x-f13cc56d665a91ff3fac47df260301afefb1a3a5.zip
vyos.util: provide single implementation for get_json_iface_options()
There had been four implementations of "ip -d -j link show interface" scattered accross the codebase. Those implementations have now been combined into a new helper: vyos.util.get_json_iface_options()
Diffstat (limited to 'smoketest/scripts/cli/test_interfaces_erspan.py')
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_erspan.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_erspan.py b/smoketest/scripts/cli/test_interfaces_erspan.py
index d0814f2fb..cbb41d0c9 100755
--- a/smoketest/scripts/cli/test_interfaces_erspan.py
+++ b/smoketest/scripts/cli/test_interfaces_erspan.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020 VyOS maintainers and contributors
+# Copyright (C) 2020-2021 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -15,20 +15,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
-import json
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
-from vyos.util import cmd
+from vyos.util import get_json_iface_options
from base_interfaces_test import BasicInterfaceTest
mtu = 1500
-def erspan_conf(interface):
- tmp = cmd(f'ip -d -j link show {interface}')
- return json.loads(tmp)[0]
-
class ERSPanTunnelInterfaceTest(BasicInterfaceTest.BaseTest):
def setUp(self):
super().setUp()
@@ -57,7 +52,7 @@ class ERSPanTunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.commit()
- conf = erspan_conf(interface)
+ conf = get_json_iface_options(interface)
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
self.assertEqual(mtu, conf['mtu'])
@@ -78,7 +73,7 @@ class ERSPanTunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.commit()
- conf = erspan_conf(interface)
+ conf = get_json_iface_options(interface)
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
self.assertEqual(mtu, conf['mtu'])