Skip to content

Commit 344e24b

Browse files
authored
Implement SSH reboot functionality
Added a function to reboot the target via SSH and updated the main execution flow to use this new function.
1 parent cd4b769 commit 344e24b

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

scripts/deploy.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ def reboot_target():
4444
except requests.exceptions.ReadTimeout:
4545
pass # NI reboots cause immediate disconnect
4646

47+
def reboot_target_via_ssh():
48+
print("Rebooting target via SSH...")
49+
50+
ssh = paramiko.SSHClient()
51+
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
52+
53+
ssh.connect(
54+
RT_IP,
55+
username=RT_USER,
56+
password=RT_PASS,
57+
look_for_keys=False,
58+
allow_agent=False
59+
)
60+
61+
try:
62+
# Run reboot command (NI RT allows this without sudo)
63+
ssh.exec_command("/sbin/reboot")
64+
print("Reboot command sent.")
65+
except Exception as e:
66+
print(f"Ignoring SSH error during reboot: {e}")
67+
finally:
68+
ssh.close()
69+
70+
4771

4872
def wait_for_target(timeout=90):
4973
print("Waiting for target to come online...")
@@ -84,7 +108,7 @@ def verify_version():
84108

85109
if __name__ == "__main__":
86110
scp_upload()
87-
reboot_target()
111+
reboot_target_via_ssh()
88112

89113
if not wait_for_target():
90114
sys.exit(1)

0 commit comments

Comments
 (0)