Package: gluon-qemu-testlab
gluon-qemu-testlabThegluon-qemu-testlab(formerly known aspynet) 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 functionNode()and connect them by
calling theconnect()function. Then gluon-qemu-testlab
does the rest:It starts a qemu instance for each node by using theimage.imgfirmware image from the root of the project directory.It connects nodes together as expected using qemus network capabilities.It configures the node though theconfig modeof gluon using an ssh session.Shell accesses to the different nodes and clients is provided.RequirementsLinux OSAt least python3.6qemupython lib asyncsshpacman-Sqemutmuxpythonpython-pip
pipinstall-rrequirements.txtQuickstartshupdate_image.sh# download an imagesudopython36scenarios/chain_4_nodes.py--run-forever# start a scenarioExample scenarioHere 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 APIstdout=node.succeed("cmd")# execute cmd via ssh and exit with failure if the command# returns with non-zero exit statusstdout=node.wait_until_succeeds("cmd")# retry executing cmd via ssh until it suceeds or timeoutsstatus,stdout=node.execute("cmd")# execute command via ssh and return the status code in# addition to stdoutprocess=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.CLIThis CLI options currently exist:--run-forever--run-tests-on-existing-instanceBecause starting up the qemu instances takes some time, the iteration process during test development can become
tedious. The--run-tests-on-existing-instanceswitch is especially helpful here. You can start one instance of pynet
using the--run-foreverswitch and then invoke scenarios using the--run-tests-on-existing-instanceswitch. This
new pynet instances will not run their own qemus instances but reuse the already spawned ones.SSH AccessDuring config mode, the ssh instances are available from the host machine at portlocalhost:22001,localhost:22002,
and so on. When the instances are configured, they are available on portslocalhost: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 gimmicsNodes support resolving names of each other.ping node1Nodes also support this command for bat-hosts.batctl tr node2To manage ssh connections, pynet automatically generates an rsa key, which is added into the image during config mode.set fastd secretnode.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.