File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
4872def wait_for_target (timeout = 90 ):
4973 print ("Waiting for target to come online..." )
@@ -84,7 +108,7 @@ def verify_version():
84108
85109if __name__ == "__main__" :
86110 scp_upload ()
87- reboot_target ()
111+ reboot_target_via_ssh ()
88112
89113 if not wait_for_target ():
90114 sys .exit (1 )
You can’t perform that action at this time.
0 commit comments