Skip to content

Commit

Permalink
Expand the reboot command to full path
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolam committed Sep 18, 2024
1 parent 0e0fc79 commit 69226c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions host_modules/systemd_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/host_modules/systemd_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
Expand Down

0 comments on commit 69226c6

Please sign in to comment.