From 071151f300b968e3c0e028835cdcb00e0aeba868 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Mon, 23 Jun 2025 15:32:35 +0200 Subject: [PATCH] clan-lib: Rename parse_deployment_address to parse_ssh_uri --- pkgs/clan-cli/clan_cli/machines/hardware.py | 2 +- pkgs/clan-cli/clan_cli/machines/install.py | 2 +- pkgs/clan-cli/clan_cli/machines/update.py | 2 +- pkgs/clan-cli/clan_cli/ssh/deploy_info.py | 6 +++--- pkgs/clan-cli/clan_lib/machines/machines.py | 4 +--- pkgs/clan-cli/clan_lib/ssh/parse.py | 2 +- pkgs/clan-cli/clan_lib/ssh/remote.py | 6 +++--- pkgs/clan-cli/clan_lib/ssh/remote_test.py | 4 ++-- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/machines/hardware.py b/pkgs/clan-cli/clan_cli/machines/hardware.py index 657735463..86da4538b 100644 --- a/pkgs/clan-cli/clan_cli/machines/hardware.py +++ b/pkgs/clan-cli/clan_cli/machines/hardware.py @@ -167,7 +167,7 @@ def update_hardware_config_command(args: argparse.Namespace) -> None: ) if args.target_host: - target_host = Remote.from_deployment_address( + target_host = Remote.from_ssh_uri( machine_name=machine.name, address=args.target_host ).override(host_key_check=host_key_check) else: diff --git a/pkgs/clan-cli/clan_cli/machines/install.py b/pkgs/clan-cli/clan_cli/machines/install.py index 739a3cea5..5943034e7 100644 --- a/pkgs/clan-cli/clan_cli/machines/install.py +++ b/pkgs/clan-cli/clan_cli/machines/install.py @@ -185,7 +185,7 @@ def install_command(args: argparse.Namespace) -> None: host_key_check = args.host_key_check if target_host_str is not None: - target_host = Remote.from_deployment_address( + target_host = Remote.from_ssh_uri( machine_name=machine.name, address=target_host_str ).override(host_key_check=host_key_check) else: diff --git a/pkgs/clan-cli/clan_cli/machines/update.py b/pkgs/clan-cli/clan_cli/machines/update.py index 37ecc3e28..e278d6f94 100644 --- a/pkgs/clan-cli/clan_cli/machines/update.py +++ b/pkgs/clan-cli/clan_cli/machines/update.py @@ -275,7 +275,7 @@ def update_command(args: argparse.Namespace) -> None: with AsyncRuntime() as runtime: for machine in machines: if args.target_host: - target_host = Remote.from_deployment_address( + target_host = Remote.from_ssh_uri( machine_name=machine.name, address=args.target_host, ).override(host_key_check=host_key_check) diff --git a/pkgs/clan-cli/clan_cli/ssh/deploy_info.py b/pkgs/clan-cli/clan_cli/ssh/deploy_info.py index c46da5f12..35fafd91d 100644 --- a/pkgs/clan-cli/clan_cli/ssh/deploy_info.py +++ b/pkgs/clan-cli/clan_cli/ssh/deploy_info.py @@ -46,7 +46,7 @@ class DeployInfo: if not host: msg = "Hostname cannot be empty." raise ClanError(msg) - remote = Remote.from_deployment_address( + remote = Remote.from_ssh_uri( machine_name="clan-installer", address=host ).override(host_key_check=host_key_check) remotes.append(remote) @@ -59,7 +59,7 @@ class DeployInfo: for addr in data.get("addrs", []): if isinstance(addr, str): - remote = Remote.from_deployment_address( + remote = Remote.from_ssh_uri( machine_name="clan-installer", address=addr, ).override(host_key_check=host_key_check, password=password) @@ -68,7 +68,7 @@ class DeployInfo: msg = f"Invalid address format: {addr}" raise ClanError(msg) if tor_addr := data.get("tor"): - remote = Remote.from_deployment_address( + remote = Remote.from_ssh_uri( machine_name="clan-installer", address=tor_addr, ).override(host_key_check=host_key_check, tor_socks=True, password=password) diff --git a/pkgs/clan-cli/clan_lib/machines/machines.py b/pkgs/clan-cli/clan_lib/machines/machines.py index 4d3148370..53479f2a7 100644 --- a/pkgs/clan-cli/clan_lib/machines/machines.py +++ b/pkgs/clan-cli/clan_lib/machines/machines.py @@ -258,8 +258,6 @@ def get_host( return None return RemoteSource( - data=Remote.from_deployment_address( - machine_name=machine.name, address=host_str - ), + data=Remote.from_ssh_uri(machine_name=machine.name, address=host_str), source=source, ) diff --git a/pkgs/clan-cli/clan_lib/ssh/parse.py b/pkgs/clan-cli/clan_lib/ssh/parse.py index 9dfe31b2f..6b5a19a15 100644 --- a/pkgs/clan-cli/clan_lib/ssh/parse.py +++ b/pkgs/clan-cli/clan_lib/ssh/parse.py @@ -8,7 +8,7 @@ if TYPE_CHECKING: from clan_lib.ssh.remote import Remote -def parse_deployment_address( +def parse_ssh_uri( *, machine_name: str, address: str, diff --git a/pkgs/clan-cli/clan_lib/ssh/remote.py b/pkgs/clan-cli/clan_lib/ssh/remote.py index 09b8f83df..de486d80f 100644 --- a/pkgs/clan-cli/clan_lib/ssh/remote.py +++ b/pkgs/clan-cli/clan_lib/ssh/remote.py @@ -21,7 +21,7 @@ from clan_lib.colors import AnsiColor from clan_lib.errors import ClanError # Assuming these are available from clan_lib.nix import nix_shell from clan_lib.ssh.host_key import HostKeyCheck, hostkey_to_ssh_opts -from clan_lib.ssh.parse import parse_deployment_address +from clan_lib.ssh.parse import parse_ssh_uri from clan_lib.ssh.sudo_askpass_proxy import SudoAskpassProxy cmdlog = logging.getLogger(__name__) @@ -90,7 +90,7 @@ class Remote: return f"{self.user}@{self.address}" @classmethod - def from_deployment_address( + def from_ssh_uri( cls, *, machine_name: str, @@ -100,7 +100,7 @@ class Remote: Parse a deployment address and return a Host object. """ - return parse_deployment_address(machine_name=machine_name, address=address) + return parse_ssh_uri(machine_name=machine_name, address=address) def run_local( self, diff --git a/pkgs/clan-cli/clan_lib/ssh/remote_test.py b/pkgs/clan-cli/clan_lib/ssh/remote_test.py index dae2f623c..6d8a094b7 100644 --- a/pkgs/clan-cli/clan_lib/ssh/remote_test.py +++ b/pkgs/clan-cli/clan_lib/ssh/remote_test.py @@ -110,7 +110,7 @@ def test_parse_deployment_address( with maybe_check_exception: machine_name = "foo" - result = Remote.from_deployment_address( + result = Remote.from_ssh_uri( machine_name=machine_name, address=test_addr, ).override(host_key_check="strict") @@ -130,7 +130,7 @@ def test_parse_deployment_address( def test_parse_ssh_options() -> None: addr = "root@example.com:2222?IdentityFile=/path/to/private/key&StrictRemoteKeyChecking=yes" - host = Remote.from_deployment_address(machine_name="foo", address=addr).override( + host = Remote.from_ssh_uri(machine_name="foo", address=addr).override( host_key_check="strict" ) assert host.address == "example.com"