Mitogen is a Python library for writing distributed self-replicating programs.
There is no requirement for installing packages, copying files around, writing shell snippets, upfront configuration, or providing any secondary link to a remote machine aside from an SSH connection. Due to its origins for use in managing potentially damaged infrastructure, the remote machine need not even have free disk space or a writeable filesystem.
It is not intended as a generic RPC framework; the goal is to provide a robust and efficient low-level API on which tools like Salt, Ansible, or Fabric can be built, and while the API is quite friendly and comparable to Fabric, ultimately it is not intended for direct use by consumer software.
The focus is to centralize and perfect the intricate dance required to run Python code safely and efficiently on a remote machine, while avoiding temporary files or large chunks of error-prone shell scripts, and supporting common privilege escalation techniques like sudo, potentially in combination with exotic connection methods such as WMI, telnet, or console-over-IPMI.
Mitogen’s main feature is enabling your Python program to bootstrap and communicate with new copies of itself under its control running on remote machines, using only an existing installed Python interpreter and SSH client, something that by default can be found on almost all contemporary machines in the wild. To accomplish bootstrap, Mitogen uses a single 400 byte SSH command line and 8KB of its own source code sent to stdin of the remote SSH connection.
The bootstrap includes a compact IO multiplexer (like Twisted or asyncio) that allows it to perform work in the background while executing your program’s code. For example, the remote context can be used to connect to a new user on the remote machine using sudo, or as an intermediary for extending the program’s domain of control outward to other machines, enabling your program to manipulate machines behind a firewall, or enable its data plane to cohere to your network topology.
Slaves are configured with a custom PEP-302 importer that forwards requests for unknown Python modules back to the host program. When your program asks a context to execute code from an unknown module, all requisite modules are transferred automatically and imported entirely in RAM without need for further configuration.
No comments:
Post a Comment