From 6091934eacdd91496c2a7d849fe64e24105a6e41 Mon Sep 17 00:00:00 2001 From: Jacob Callahan Date: Thu, 26 Sep 2024 15:14:50 -0400 Subject: [PATCH] Enable timeouts for command execution when using Hussh Previosuly it was impossible to set command-level timeouts when using Hussh as the backend. In fact, due to the way the Host objects acquired their Hussh connections, timeouts were always left to the default. Now, with Hussh 0.1.7, we can pass a command-specific timeout. --- broker/binds/hussh.py | 4 +--- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/broker/binds/hussh.py b/broker/binds/hussh.py index f983b354..9b869218 100644 --- a/broker/binds/hussh.py +++ b/broker/binds/hussh.py @@ -91,9 +91,7 @@ def remote_copy(self, source, dest_host, dest_path=None, ensure_dir=True): def run(self, command, timeout=0): """Run a command on the host and return the results.""" - # TODO support timeout parameter - result = self.session.execute(command) - + result = self.session.execute(command, timeout=helpers.translate_timeout(timeout)) # Create broker Result from hussh SSHResult return helpers.Result( status=result.status, diff --git a/pyproject.toml b/pyproject.toml index cb393998..645f5fee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ ssh2_py311 = ["ssh2-python"] ssh2_python = ["ssh2-python"] ssh2_python312 = ["ssh2-python312"] ansible_pylibssh = ["ansible-pylibssh"] -hussh = ["hussh"] +hussh = ["hussh>=0.1.7"] [project.scripts] broker = "broker.commands:cli"