comnetsemu.node module

About: ComNetsEmu Node

class comnetsemu.node.APPContainer(name: str, dhost: str, dimage: str, dins, dcmd: str | None = None)

Bases: object

Application containers that should run inside a DockerHost.

A wrapper class to hide the implementation details of used container runtime. For example, it should expose the same API for different container runtimes like Docker, LXC or CRI-O (If ComNetsEmu project decides to support them).

getCurrentStats()

Get decoded current stats of the Docker container.

getLogs()

Get logs from this container.

class comnetsemu.node.DockerHost(name: str, dimage: str, docker_args: dict | None = None, dcmd: str | None = None, ishell: str = 'bash', ishell_args: str = '--norc -is', **kwargs)

Bases: Host

Node that represents a docker container.

This part is inspired by: - http://techandtrains.com/2014/08/21/docker-container-as-mininet-host/ - DockerHost implementation from Patrick Ziegler (patrick.ziegler@tu-dresden.de)

cleanup()

Help python collect its garbage.

cmd(*args, **kwargs)

Send a command, wait for output, and return it. cmd: string

docker_args_default = {'auto_remove': True, 'detach': True, 'init': True, 'labels': {'comnetsemu': 'dockerhost'}, 'network_mode': 'bridge', 'privileged': True, 'stdin_open': True, 'tty': True}
popen(*args, **kwargs)

Return a Popen() object in node’s namespace args: Popen() args, single list, or string kwargs: Popen() keyword args

sendCmd(*args, **kwargs)

Send a command, followed by a command to echo a sentinel, and return without waiting for the command to complete.

setIP(ip, prefixLen=8, intf=None, **kwargs)

Set the IP address for an interface. intf: intf or intf name ip: IP address as a string prefixLen: prefix length, e.g. 8 for /8 or 16M addrs kwargs: any additional arguments for intf.setIP

startShell()

Start a shell process for running commands

terminate()

Stop docker container