91 | | 3. **Termination Control**: We also worked on adding more specific termination control for Maestros. Previously, running the end_experiment script would terminate all Maestros, or at least attempt to do so. Hence, even if only one was running, it would try and connect to each every Maestro, of which there are more than 30 total, and this process was inefficient. Hence, we wanted to add a feature that could shut off specified Maestros and give the user more control and efficient workflow when interacting with the Maestros. Still a work in progress, with tr and it should be finalized by the upcoming week. |
| 93 | {{{#!python |
| 94 | client = paramiko.client.SSHClient() |
| 95 | client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
| 96 | try: |
| 97 | print(f"Connecting to {ip}...") |
| 98 | client.connect(ip, username=username, password=password, timeout=1) |
| 99 | print(f"Connected to {ip}. Shutting down...") |
| 100 | client.exec_command("sudo shutdown -h now") |
| 101 | print(f"{ip} is shutting down.") |
| 102 | except paramiko.AuthenticationException: |
| 103 | print(f"Authentication failed for {ip}. Check username and password.") |
| 104 | except paramiko.SSHException as ssh_err: |
| 105 | print(f"SSH error occurred for {ip}: {str(ssh_err)}") |
| 106 | except socket.timeout: |
| 107 | print(f"Connection to {ip} timed out. Check if the Pi is plugged in.") |
| 108 | except Exception as e: |
| 109 | print(f"Failed to connect to {ip}: {str(e)}") |
| 110 | finally: |
| 111 | client.close() |
| 112 | }}} |
| 113 | |
| 114 | *Shutdown Maestros image:[[Image(https://online.publuu.com/594674/1333239)]] |
| 115 | |
| 116 | 3. **Termination Control**: We also worked on adding more specific termination control for Maestros. Previously, running the end_experiment script would terminate all Maestros, or at least attempt to do so. Hence, even if only one was running, it would try and connect to each every Maestro, of which there are more than 30 total, and this process was inefficient. Hence, we wanted to add a feature that could shut off specified Maestros and give the user more control and efficient workflow when interacting with the Maestros. It is still a work in progress, with tr, and it should be finalized by the upcoming week. |