gluon-qemu-testlab
The gluon-qemu-testlab (formerly known as pynet) tool helps
in creating virtual mesh topologies
with gluon firmwares using the qemu virtualization
technology. It provides a simple language, where you can
build your topology file in. You can create nodes by
simply calling a function Node() and connect them by
calling the connect() function. Then gluon-qemu-testlab
does the rest:
- It starts a qemu instance for each node by using the
image.imgfirmware image from the root of the project directory. - It connects nodes together as expected using qemus network capabilities.
- It configures the node though the config mode of gluon using an ssh session.
- Shell accesses to the different nodes and clients is provided.
Requirements
- Linux OS
- At least python3.6
- qemu
- python lib asyncssh
pacman -S qemu tmux python python-pip
pip install -r requirements.txt
Quickstart
sh update_image.sh # download an image
sudo python36 scenarios/chain_4_nodes.py --run-forever # start a scenario
Example scenario
Here we connect three nodes in a chain. The syntax is standard python syntax.
#!/usr/bin/env python3
import sys
sys.path.append(".")
from pynet import *
a = Node()
b = Node()
c = Node()
connect(a, b)
connect(b, c)
start()
# tests could go here
finish()
Testing API
stdout = node.succeed("cmd") # execute cmd via ssh and exit with failure if the command
# returns with non-zero exit status
stdout = node.wait_until_succeeds("cmd") # retry executing cmd via ssh until it suceeds or timeouts
status, stdout = node.execute("cmd") # execute command via ssh and return the status code in
# addition to stdout
process = node.execute_in_background("cmd") # start a command in background (e.g. a server process)
process.close() # send SIGINT to the command and wait until it exits.
CLI
This CLI options currently exist:
--run-forever--run-tests-on-existing-instance
Because starting up the qemu instances takes some time, the iteration process during test development can become
tedious. The --run-tests-on-existing-instance switch is especially helpful here. You can start one instance of pynet
using the --run-forever switch and then invoke scenarios using the --run-tests-on-existing-instance switch. This
new pynet instances will not run their own qemus instances but reuse the already spawned ones.
SSH Access
During config mode, the ssh instances are available from the host machine at port localhost:22001, localhost:22002,
and so on. When the instances are configured, they are available on ports localhost:22101, localhost:22102, and
so on.
When they are configured, you can use the symlinked scripts:
ssh/node1.shssh/node2.sh- ...
to easily access the nodes. They provide a little more convinience as they disable known hosts checks.
Advanced gimmics
- Nodes support resolving names of each other.
ping node1 - Nodes also support this command for bat-hosts.
batctl tr node2 - To manage ssh connections, pynet automatically generates an rsa key, which is added into the image during config mode.
set fastd secret
node.set_fastd_secret('e88b6e7adf88ffb9448293ab008f2fde9a06d012973b7a73cb4947781f6020f2')
currently disabled features:
- Client namespaces using network namespaces.
- Spawing firefox as a client of a router is also possible. This is very helpful to see the statuspage of a router. Please note, that the shells opened by pynet are root shells. So if you directly start firefox inside such a shell, it has root access.
Metadata
Release files for gluon-qemu-testlab 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gluon-qemu-testlab-0.0.5.tar.gz | 9.8 kB | Without provenance | Details for gluon-qemu-testlab-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gluon_qemu_testlab-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for gluon_qemu_testlab-0.0.5-py3-none-any.whl |
Total release size: 20.3 kB
Release files / gluon-qemu-testlab-0.0.5.tar.gz
| Download URL | gluon-qemu-testlab-0.0.5.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4de8d5ee8cf483193d304bf0e36526b3d9ca621fdff6d8ed97ef61193afe633
|
|
BLAKE2b-256 checksum How to use checksums |
23d3c85e2e2c4084f721d40137015a53c1d07d1f0ef5df65f90a40e58d2af36f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.1
|
Release files / gluon_qemu_testlab-0.0.5-py3-none-any.whl
| Download URL | gluon_qemu_testlab-0.0.5-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61f656336a01a4f9abf6afcf6fc09c717796698c13cb76e22e21bab137b982f8
|
|
BLAKE2b-256 checksum How to use checksums |
7ed4358dc2582f16af8c9a2e4d8e17f0ed52b7e07c7dc63ee92c99b711b1812d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.1
|
Security for gluon-qemu-testlab 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.