From 5ec47a5ed7029280adc88ae4c84b77ac93373389 Mon Sep 17 00:00:00 2001 From: MiningPickaxe <13851035+MiningPickaxe@users.noreply.github.com> Date: Thu, 18 Jun 2026 02:28:20 +0200 Subject: [PATCH 1/2] Fix issue of trying to decode a str This fixes an error where _parse_iface_file tries to decode a str. The output of the command getting executed is already getting decoded in coriolis/utils.py exec_cmd_ssh introduced in commit 539fabb9d302b3915cda19357ba0d0ea6d33d25f --- coriolis/osmorphing/netpreserver/interfaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coriolis/osmorphing/netpreserver/interfaces.py b/coriolis/osmorphing/netpreserver/interfaces.py index 19fbae985..5c5ebf888 100644 --- a/coriolis/osmorphing/netpreserver/interfaces.py +++ b/coriolis/osmorphing/netpreserver/interfaces.py @@ -31,7 +31,7 @@ def _parse_iface_file(interface_file): curr_ip_address = None curr_iface = None interfaces_contents = self.osmorphing_tool._read_file_sudo( - interface_file).decode() + interface_file) LOG.debug( "Fetched %s contents: %s", interface_file, interfaces_contents) for line in interfaces_contents.splitlines(): From 6273eb6d751316515c6add499ea7968f29d037ef Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 21 Jul 2026 15:11:22 +0000 Subject: [PATCH 2/2] Update netpreserver tests "_read_file_sudo" no longer returns a byte array, it actually decodes the string. The tests need to be updated accordingly, avoiding type mismatches. --- coriolis/tests/osmorphing/netpreserver/test_interfaces.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coriolis/tests/osmorphing/netpreserver/test_interfaces.py b/coriolis/tests/osmorphing/netpreserver/test_interfaces.py index 5ede0fa63..2366547f6 100644 --- a/coriolis/tests/osmorphing/netpreserver/test_interfaces.py +++ b/coriolis/tests/osmorphing/netpreserver/test_interfaces.py @@ -69,7 +69,7 @@ def test_parse_network_basic(self, mock_test_path, mock_exec_cmd_chroot, "iface eth1 inet dhcp\n" "address 192.168.1.20/24\n" ) - mock_read_file_sudo.return_value = interfaces_content.encode() + mock_read_file_sudo.return_value = interfaces_content mock_test_path.return_value = True mock_exec_cmd_chroot.return_value = "" @@ -109,7 +109,7 @@ def test_parse_network_with_source(self, mock_test_path, mock_test_path.return_value = True mock_exec_cmd_chroot.return_value = extra_file mock_read_file_sudo.side_effect = ( - main_content.encode(), extra_content.encode() + main_content, extra_content ) self.netpreserver.parse_network() @@ -136,7 +136,7 @@ def test_parse_network_with_trailing_hwaddress(self, mock_test_path, interfaces_content = ( "hwaddress ether 00:11:22:33:44:55\n" ) - mock_read_file_sudo.return_value = interfaces_content.encode() + mock_read_file_sudo.return_value = interfaces_content mock_test_path.return_value = True mock_exec_cmd_chroot.return_value = ""