host.remote_host¶
Abstract base for network-reached hosts.
RemoteHost is the common ancestor of every host class that talks to a
target across a network — UnixHost (SSH/Telnet to a bash shell),
EmbeddedHost (telnet to an RTOS shell), and any future siblings such
as a Windows-host class. It is deliberately distinct from LocalHost,
which runs commands on the local machine and shares no network plumbing.
History: this name used to belong to the concrete SSH/Telnet bash host.
That class is now UnixHost; RemoteHost is the abstract parent.
The split makes the OS family of a host explicit (lab data carries an
os_type field) and gives embedded targets a place to live alongside Unix
ones without lying about their shape.
RemoteHost is intentionally not a dataclass. The concrete subclasses
are @dataclass(slots=True) and the field-ordering rules of dataclass
inheritance (no non-default field after a default one) make a shared dataclass
base awkward. Instead this base owns the behavior shared by every remote
host — host naming and the SshHopTransport machinery — and declares, as
bare annotations, the instance attributes those shared methods rely on. Each
concrete subclass supplies the real @dataclass fields.
- otto.host.remote_host.make_host_id(element: str, element_id: int | None, board: str | None, slot: int | None) str¶
Compose a host’s
idfrom its identity fields — the single source of the id format, called byRemoteHost._generate_idand by host_preferences selector matching (so a selector regex matches the same string a built host reports).element_idrenders as its number;board/slotlower-case with a_join.
- otto.host.remote_host.OsType¶
Profile selector recorded on a host (the
os_typefield).Built-ins:
unix(UnixHost),embedded(genericEmbeddedHost),zephyr(ZephyrHost). Custom profiles add more names. The base family (unix vs embedded) is derived from the host class, not from this string.
- class otto.host.remote_host.RemoteHost¶
Bases:
BaseHostAbstract base class for any host reached over a network.
Concrete subclasses (
UnixHost,EmbeddedHost) supply the transport-specific session/transfer machinery as@dataclassfields. Do not instantiate this class directly.The bare annotations below are the instance-attribute contract every concrete subclass must satisfy. They carry no values, so they create no slots and do not participate in the subclasses’
@dataclassfield collection — they exist purely so the shared methods here (and callers holding aRemoteHost-typed reference) type-check.- os_type : OsType¶
Profile selector recorded on this host (see
OsType). The base family (unix vs embedded) is derived from the host class, not this string.
- default_dest_dir : Path¶
Per-host default directory that
put/getresolve a relative or emptydest_diragainst. Lets a fan-out helper likedo_for_all_hostspass one generic destination (Path()) and have each host land the files where its filesystem actually lives — e.g./RAM:on a Zephyr FAT target,/lfson a Zephyr LittleFS target. Defaults toPath()on Unix, which preserves the existing “relative path lands in the SSH user’s home” behavior.
- snmp : SnmpOptions | None¶
Optional per-host SNMP polling config (lab
snmpblock), or None. When set, otto’s monitor collects this host over SNMP instead of by running shell commands. Declared on both concrete subclasses; seeSnmpOptions.
- max_filename_len : int¶
Upper bound on the basename length (including extension) accepted by the target’s filesystem. Defaults to
255on every concrete subclass — the LinuxNAME_MAX, also the cap for ext4 / XFS / Btrfs / NTFS and the typical LittleFS ceiling. Override per-host when the firmware enforces a tighter limit (e.g.32for a Zephyr build that setsCONFIG_FS_FATFS_MAX_LFN=32, or12for a stock FAT 8.3 build without LFN support).put/getreject over-limit names up front with a clear message instead of letting the device produce an opaque error like-ENOENTorFile name too long.
- interfaces : dict[str, str]¶
Named secondary interface addresses, keyed by interface name (e.g.
{"mgmt": "10.0.0.5", "data": "192.168.1.5"}). The primary address staysip; this map is additive and optional (empty by default). Resolve a name (or pass a literal through) withaddress_for().
- power_control : PowerController | None¶
Pluggable power backend (see
power_control).
- async verify_connection() CommandStatus¶
-
async is_reachable(timeout: float =
10.0) bool¶ Probe by attempting a connection (no command), bounded by timeout.
- address_for(name_or_literal: str) str¶
Resolve an interface name to its address, or pass a literal through.
If name_or_literal is a key in
interfaces, return that interface’s address; otherwise return the value unchanged (it is taken to be a literal address such asipor an explicit IP). This lets a host’ssnmp.addressname a secondary interface without otto having to distinguish names from literals.