From b7523fd469424844e6a4c1ac73725afaa109ca8b Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Sat, 11 May 2024 19:03:24 +0100 Subject: [PATCH 1/2] Fix modify devices --- framework/python/src/common/util.py | 3 ++- framework/python/src/net_orc/ip_control.py | 4 +++- framework/python/src/net_orc/network_orchestrator.py | 2 ++ testing/api/test_api.py | 6 +----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/framework/python/src/common/util.py b/framework/python/src/common/util.py index e588640ae..856217add 100644 --- a/framework/python/src/common/util.py +++ b/framework/python/src/common/util.py @@ -46,7 +46,8 @@ def run_command(cmd, output=True): LOGGER.debug('Command succeeded: ' + cmd) if output: out = stdout.strip().decode('utf-8') - LOGGER.debug('Command output: ' + out) + if out is not None and len(out) != 0: + LOGGER.debug('Command output: ' + out) return out, stderr else: return success diff --git a/framework/python/src/net_orc/ip_control.py b/framework/python/src/net_orc/ip_control.py index 1eeafc1a9..ddd0a17e2 100644 --- a/framework/python/src/net_orc/ip_control.py +++ b/framework/python/src/net_orc/ip_control.py @@ -42,10 +42,12 @@ def add_namespace(self, namespace): return success def check_interface_status(self, interface_name): - output = util.run_command(cmd=f'ip link show {interface_name}',output=True) + output = util.run_command(cmd=f'ip link show {interface_name}', output=True) if 'state DOWN ' in output[0]: + LOGGER.debug('Device interface is down') return False else: + LOGGER.debug('Device interface is up') return True def delete_link(self, interface_name): diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index aa23f1918..0ea342bad 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -258,6 +258,8 @@ def _start_device_monitor(self, device): sniffer.stop() self._session.set_status('Cancelled') LOGGER.error('Device interface disconnected, cancelling Testrun') + + LOGGER.debug('Writing packets to monitor.pcap') wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), self._monitor_packets) self._monitor_in_progress = False diff --git a/testing/api/test_api.py b/testing/api/test_api.py index b5a4f7978..871a016d5 100644 --- a/testing/api/test_api.py +++ b/testing/api/test_api.py @@ -236,11 +236,7 @@ def test_get_system_interfaces(testrun): def test_modify_device(testing_devices, testrun): - with open( - os.path.join( - DEVICES_DIRECTORY, testing_devices[1] - ) - ) as f: + with open(testing_devices[1], encoding="utf-8") as f: local_device = json.load(f) mac_addr = local_device["mac_addr"] From 85ca663a9ce0fabf86332d47cd128f282014befb Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Tue, 21 May 2024 14:09:49 +0100 Subject: [PATCH 2/2] Remove excess logging --- framework/python/src/net_orc/ip_control.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/python/src/net_orc/ip_control.py b/framework/python/src/net_orc/ip_control.py index ddd0a17e2..84296112e 100644 --- a/framework/python/src/net_orc/ip_control.py +++ b/framework/python/src/net_orc/ip_control.py @@ -44,10 +44,8 @@ def add_namespace(self, namespace): def check_interface_status(self, interface_name): output = util.run_command(cmd=f'ip link show {interface_name}', output=True) if 'state DOWN ' in output[0]: - LOGGER.debug('Device interface is down') return False else: - LOGGER.debug('Device interface is up') return True def delete_link(self, interface_name):