summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_interfaces_macsec.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_macsec.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_macsec.py')
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_macsec.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_macsec.py b/smoketest/scripts/cli/test_interfaces_macsec.py
index d6bef993a..2f1898b6f 100755
--- a/smoketest/scripts/cli/test_interfaces_macsec.py
+++ b/smoketest/scripts/cli/test_interfaces_macsec.py
@@ -25,6 +25,7 @@ from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.util import cmd
from vyos.util import read_file
+from vyos.util import get_json_iface_options
from vyos.util import process_named_running
def get_config_value(interface, key):
@@ -33,13 +34,7 @@ def get_config_value(interface, key):
return tmp[0]
def get_cipher(interface):
- """ Returns the used encapsulation protocol for given interface.
- If interface does not exist, None is returned.
- """
- if not os.path.exists(f'/sys/class/net/{interface}'):
- return None
- from json import loads
- tmp = loads(cmd(f'ip -d -j link show {interface}'))[0]
+ tmp = get_json_iface_options(interface)
return tmp['linkinfo']['info_data']['cipher_suite'].lower()
class MACsecInterfaceTest(BasicInterfaceTest.BaseTest):