Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 7427850

Browse files
committed
driver-ssh: add commodity properties
Add command, identity, and username as class properties for SSHWrapperClient. Signed-off-by: Albert Esteve <aesteve@redhat.com>
1 parent 3d65e4b commit 7427850

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,30 @@ def stream(self, method="connect"):
9494
async def stream_async(self, method):
9595
return await self.tcp.stream_async(method)
9696

97+
@property
98+
def command(self) -> str:
99+
"""Get the base SSH command"""
100+
return self.call("get_ssh_command")
101+
102+
@property
103+
def identity(self) -> str | None:
104+
"""
105+
Get the SSH identity (private key) as a string.
106+
107+
Returns:
108+
The SSH identity key content, or None if not configured.
109+
110+
Raises:
111+
ConfigurationError: If `ssh_identity_file` is configured on the
112+
driver but cannot be read.
113+
"""
114+
return self.call("get_ssh_identity")
115+
116+
@property
117+
def username(self) -> str:
118+
"""Get the default SSH username"""
119+
return self.call("get_default_username")
120+
97121
def run(self, options: SSHCommandRunOptions, args) -> SSHCommandRunResult:
98122
"""Run SSH command with the given parameters and arguments"""
99123
# Get SSH command and default username from driver

packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,3 +692,18 @@ def test_ssh_identity_temp_file_cleanup_error():
692692

693693
assert result.return_code == 0
694694
assert result.stdout == "some stdout"
695+
696+
697+
def test_ssh_client_properties():
698+
"""Test that the client properties correctly reflect the driver configuration"""
699+
instance = SSHWrapper(
700+
children={"tcp": TcpNetwork(host="127.0.0.1", port=22)},
701+
default_username="testuser",
702+
ssh_identity=TEST_SSH_KEY,
703+
ssh_command="my-ssh-command",
704+
)
705+
706+
with serve(instance) as client:
707+
assert client.username == "testuser"
708+
assert client.identity == TEST_SSH_KEY
709+
assert client.command == "my-ssh-command"

0 commit comments

Comments
 (0)