From 5faf240a122297388f41fe8e77580b3b28e09393 Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Fri, 28 Feb 2025 21:36:41 +0100 Subject: [PATCH] Add SSHControllablePingableSystem --- dashboard/system.py | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/dashboard/system.py b/dashboard/system.py index 7432822..8c4cc4a 100644 --- a/dashboard/system.py +++ b/dashboard/system.py @@ -193,23 +193,22 @@ class PingableWOLSystem(WakeOnLanMixin, PingableSystem): return actions -# Pingable + WOL + SSH +# Pingable + SSH -class SSHControllablePingableWOLSystem(SSHMixin, PingableWOLSystem): +class SSHControllablePingableSystem(SSHMixin, PingableSystem): def __init__( self, name, description, - host_ip: str, host_mac: str, + host_ip: str, ssh_commands: Dict[str, str], # dict containing "action name": "command ..." ssh_user: str, ssh_key_file: str, ssh_key_passphrase: str = None, ssh_port: int = 22, ): - super().__init__(name, description, host_ip, host_mac) + super().__init__(name, description, host_ip) self.host = host_ip - self.host_mac = host_mac self.ssh_commands = ssh_commands self.ssh_user = ssh_user self.ssh_key_file = ssh_key_file @@ -222,6 +221,39 @@ class SSHControllablePingableWOLSystem(SSHMixin, PingableWOLSystem): actions.extend(self.actions_from_ssh_commands()) return actions + +# Pingable + WOL + SSH + + +class SSHControllablePingableWOLSystem(WakeOnLanMixin, SSHControllablePingableSystem): + + def __init__( + self, name, description, + host_ip: str, host_mac: str, + ssh_commands: Dict[str, str], # dict containing "action name": "command ..." + ssh_user: str, + ssh_key_file: str, + ssh_key_passphrase: str = None, + ssh_port: int = 22, + ): + super().__init__( + name, description, host_ip, + ssh_commands=ssh_commands, + ssh_user=ssh_user, + ssh_key_file=ssh_key_file, + ssh_key_passphrase=ssh_key_passphrase, + ssh_port=ssh_port + ) + self.host_mac = host_mac + + + def get_actions(self) -> List[Action]: + actions = super().get_actions() + if self.state != SystemState.OK: + actions.append(Action("Wake On LAN", self.wakeonlan)) + return actions + + # alias :) Doggo = SSHControllablePingableWOLSystem