Moler is an open-source Python library developed by Nokia for building automated tests. It provides well-defined, composable “bricks” — each with a clearly scoped responsibility and consistent API — that you assemble into test scripts for terminals, networked devices, and distributed systems.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nokia/moler/llms.txt
Use this file to discover all available pages before exploring further.
Core building blocks
Every Moler component follows the same construction pattern, so adding new ones is straightforward. Commands as self-reliant objects A command encapsulates both triggering an action on a device and parsing the resulting output. The caller does not need to know how the command is sent, how output is received, or how it is parsed — only how to start it and retrieve its result. Event observers and callbacks Event observers watch a connection for asynchronous data (alarms, unexpected reboots, prompts) and fire callbacks when that data appears. This enables online reaction rather than offline post-processing of logs. Background execution Commands and observers can run in the background while other work proceeds in the foreground. This makes it straightforward to run multiple operations in parallel and handle unexpected system behavior without blocking. State machine devices Devices are modeled as state machines. State transitions — such as opening an SSH connection to reach a remote shell — are defined in configuration, not in test code. The test script saysgoto_state("UNIX_REMOTE"); the configuration describes how to get there. This separates test logic from infrastructure topology.
Automatic connection logging
Moler automatically logs all data flowing through every device connection. A high-level moler.log records command activity across all devices. Per-device logs (e.g., moler.RebexTestMachine.log) record the raw bytes sent and received. Logs can be rotated by size or time and compressed automatically.
Command as future
Moler’s central design idea is the Command as Future. A command object is both:- A function-like object that actively triggers an action on a device by sending a command string over a connection, then parses the output.
- A future-like object that stores the result of that parsing and exposes APIs to check completion, retrieve results, and handle errors.
concurrent.futures and asyncio, where an external executor or event loop starts the callable. In Moler, the command is self-executable:
timeout parameter on await_done is required. Commands are not expected to run forever — the caller must specify the worst-case wait time.
A motivating example
Find all Python processes running on a local machine:Reuse freedom
Moler is designed for incremental adoption. You can use as much or as little as you need:- Use YAML configuration files, or configure entirely from Python dicts.
- Use high-level
DeviceFactory, or create command objects directly with a connection. - Use the provided connection types, or supply your own.
Quickstart
Get a working script running in minutes.
Installation
Install Moler and review system requirements.