Merge pull request 'machines update: support local build' (#4515) from local-build into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4515
This commit is contained in:
@@ -90,7 +90,7 @@ def run_machine_hardware_info(
|
||||
"--show-hardware-config",
|
||||
]
|
||||
|
||||
with target_host.ssh_control_master() as ssh, ssh.become_root() as sudo_ssh:
|
||||
with target_host.host_connection() as ssh, ssh.become_root() as sudo_ssh:
|
||||
out = sudo_ssh.run(config_command, opts=RunOpts(check=False))
|
||||
if out.returncode != 0:
|
||||
if "nixos-facter" in out.stderr and "not found" in out.stderr:
|
||||
|
||||
@@ -17,7 +17,7 @@ from clan_lib.colors import AnsiColor
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.machines.machines import Machine
|
||||
from clan_lib.nix import nix_command, nix_metadata
|
||||
from clan_lib.ssh.remote import Remote
|
||||
from clan_lib.ssh.host import Host
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -37,7 +37,7 @@ def is_local_input(node: dict[str, dict[str, str]]) -> bool:
|
||||
return local
|
||||
|
||||
|
||||
def upload_sources(machine: Machine, ssh: Remote, force_fetch_local: bool) -> str:
|
||||
def upload_sources(machine: Machine, ssh: Host, force_fetch_local: bool) -> str:
|
||||
env = ssh.nix_ssh_env(os.environ.copy())
|
||||
|
||||
flake_url = (
|
||||
@@ -110,8 +110,8 @@ def upload_sources(machine: Machine, ssh: Remote, force_fetch_local: bool) -> st
|
||||
@API.register
|
||||
def run_machine_update(
|
||||
machine: Machine,
|
||||
target_host: Remote,
|
||||
build_host: Remote | None,
|
||||
target_host: Host,
|
||||
build_host: Host | None,
|
||||
force_fetch_local: bool = False,
|
||||
) -> None:
|
||||
"""Update an existing machine using nixos-rebuild or darwin-rebuild.
|
||||
@@ -126,13 +126,13 @@ def run_machine_update(
|
||||
"""
|
||||
|
||||
with ExitStack() as stack:
|
||||
target_host = stack.enter_context(target_host.ssh_control_master())
|
||||
target_host = stack.enter_context(target_host.host_connection())
|
||||
|
||||
# If no build host is specified, use the target host as the build host.
|
||||
if build_host is None:
|
||||
build_host = target_host
|
||||
else:
|
||||
build_host = stack.enter_context(build_host.ssh_control_master())
|
||||
build_host = stack.enter_context(build_host.host_connection())
|
||||
|
||||
# Some operations require root privileges on the target host.
|
||||
target_host_root = stack.enter_context(target_host.become_root())
|
||||
|
||||
Reference in New Issue
Block a user