From 69226c67051eff032d7ac4b4219929c8c0430e44 Mon Sep 17 00:00:00 2001 From: Vasundhara Volam Date: Wed, 18 Sep 2024 22:54:20 +0000 Subject: [PATCH] Expand the reboot command to full path --- host_modules/systemd_service.py | 4 ++-- tests/host_modules/systemd_service_test.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/host_modules/systemd_service.py b/host_modules/systemd_service.py index f96988c1..c77a2a45 100644 --- a/host_modules/systemd_service.py +++ b/host_modules/systemd_service.py @@ -54,9 +54,9 @@ def stop_service(self, service): @host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is') def execute_reboot(self, rebootmethod): if rebootmethod in REBOOTMETHOD_COLD_BOOT_VALUES: - cmd = ['reboot'] + cmd = ['/usr/local/bin/reboot'] elif rebootmethod in REBOOTMETHOD_HALT_BOOT_VALUES: - cmd = ['sudo reboot','-p'] + cmd = ['/usr/local/bin/reboot','-p'] else: return EXIT_FAILURE, "{}: Invalid reboot method: {}".format(MOD_NAME, rebootmethod) diff --git a/tests/host_modules/systemd_service_test.py b/tests/host_modules/systemd_service_test.py index 7189f2bd..e8e1a363 100644 --- a/tests/host_modules/systemd_service_test.py +++ b/tests/host_modules/systemd_service_test.py @@ -111,7 +111,7 @@ def test_execute_reboot_cold(self, MockInit, MockBusName, MockSystemBus): # Assert the correct command was called call_args = mock_run.call_args[0][0] - assert "reboot" in call_args, "Expected reboot command in subprocess call" + assert "/usr/local/bin/reboot" in call_args, "Expected reboot command in subprocess call" # Assert the return values are correct assert ret == test_ret, f"Expected return code {test_ret}, got {ret}" @@ -138,7 +138,7 @@ def test_execute_reboot_halt(self, MockInit, MockBusName, MockSystemBus): # Assert the correct command was called call_args = mock_run.call_args[0][0] - assert "sudo reboot" in call_args, "Expected reboot command in subprocess call" + assert "/usr/local/bin/reboot" in call_args, "Expected reboot command in subprocess call" # Assert the return values are correct assert ret == test_ret, f"Expected return code {test_ret}, got {ret}"