From 01d7ecabe457fee6df597bd3e181c382fd8da5bb Mon Sep 17 00:00:00 2001 From: Dawei Huang Date: Tue, 21 Jan 2025 21:55:08 +0000 Subject: [PATCH] change name from list_images to list_image. --- host_modules/image_service.py | 7 ++++--- tests/host_modules/image_service_test.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/host_modules/image_service.py b/host_modules/image_service.py index b8328eba..6a765884 100644 --- a/host_modules/image_service.py +++ b/host_modules/image_service.py @@ -138,7 +138,7 @@ def checksum(self, file_path, algorithm): @host_service.method( host_service.bus_name(MOD_NAME), in_signature="", out_signature="is" ) - def list_images(self): + def list_image(self): """ List the current, next, and available SONiC images. @@ -156,8 +156,9 @@ def list_images(self): logger.info("List result: {}".format(result)) return 0, json.dumps(result) except subprocess.CalledProcessError as e: - logger.error("Failed to list images: {} with return code {}".format(e.output.decode(), e.returncode)) - return e.returncode, json.dumps({"error": "Failed to list images: {}".format(e.output.decode())}) + msg = "Failed to list images: command {} failed with return code {} and message {}".format(e.cmd, e.returncode, e.output.decode()) + logger.error(msg) + return e.returncode, msg def _parse_sonic_installer_list(self, output): """ diff --git a/tests/host_modules/image_service_test.py b/tests/host_modules/image_service_test.py index 94257794..75d86f68 100644 --- a/tests/host_modules/image_service_test.py +++ b/tests/host_modules/image_service_test.py @@ -392,7 +392,7 @@ def test_list_image_success(self, mock_check_output, MockInit, MockBusName, Mock mock_check_output.return_value = mock_output.encode() # Act - rc, images_json = image_service.list_images() + rc, images_json = image_service.list_image() images = json.loads(images_json) # Assert