ipmininet.router package

This module defines a modular router that is able to support multiple daemons

class ipmininet.router.IPNode(name: str, config: Union[Type[ipmininet.router.config.base.NodeConfig], Tuple[Type[ipmininet.router.config.base.NodeConfig], Dict[KT, VT]]] = <class 'ipmininet.router.config.base.NodeConfig'>, cwd='/tmp', process_manager: Type[ipmininet.router.__router.ProcessHelper] = <class 'ipmininet.router.__router.ProcessHelper'>, use_v4=True, use_v6=True, create_logdirs=True, *args, **kwargs)

Bases: mininet.node.Node

A Node which manages a set of daemons

Most of the heavy lifting for this node should happen in the associated config object.

Parameters:
  • config – The configuration generator for this node. Either a class or a tuple (class, kwargs)
  • cwd – The base directory for temporary files such as configs
  • process_manager – The class that will manage all the associated processes for this node
  • use_v4 – Whether this node has IPv4
  • use_v6 – Whether this node has IPv6
get(key, val=None)

Check for a given key in the node parameters

network_ips() → Dict[str, List[str]]

Return all the addresses of the nodes connected directly or not to this node

start()

Start the node: Configure the daemons, set the relevant sysctls, and fire up all needed processes

terminate()

Stops this node and sets back all sysctls to their old values

class ipmininet.router.Router(name, config: Union[Type[ipmininet.router.config.base.RouterConfig], Tuple[Type[ipmininet.router.config.base.RouterConfig], Dict[KT, VT]]] = <class 'ipmininet.router.config.base.BasicRouterConfig'>, password='zebra', lo_addresses: Sequence[Union[str, ipaddress.IPv4Interface, ipaddress.IPv6Interface]] = (), *args, **kwargs)

Bases: ipmininet.router.__router.IPNode, ipmininet.utils.L3Router

The actual router, which manages a set of daemons

Parameters:
  • password – The password for the routing daemons vtysh access
  • lo_addresses – The list of addresses to set on the loopback interface
asn
class ipmininet.router.OpenrRouter(name, *args, config: Type[ipmininet.router.config.base.OpenrRouterConfig], lo_addresses: Optional[Sequence[Union[str, ipaddress.IPv4Interface, ipaddress.IPv6Interface]]] = None, privateDirs=['/tmp'], **kwargs)

Bases: ipmininet.router.__router.Router

OpenR router with private ‘/tmp’ dir to handle unix sockets created by the OpenR daemon

class ipmininet.router.ProcessHelper(node: ipmininet.router.__router.IPNode)

Bases: object

This class holds processes that are part of a given family, e.g. routing daemons. This also provides the abstraction to execute a new process, currently in a mininet namespace, but could be extended to execute in a different environment.

Parameters:node – The object to use to create subprocesses.
call(*args, **kwargs) → Optional[str]

Call a command, wait for it to end and return its output.

Parameters:
  • args – the command + arguments
  • kwargs – key-val arguments, as used in subprocess.Popen
get_process(pid)

Return a given process handle in this family

Parameters:pid – a process index, as return by popen
pexec(*args, **kw) → Tuple[str, str, int]

Call a command, wait for it to terminate and save stdout, stderr and its return code

popen(*args, **kwargs) → int

Call a command and return a Popen handle to it.

Parameters:
  • args – the command + arguments
  • kwargs – key-val arguments, as used in subprocess.Popen
Returns:

a process index in this family

terminate()

Terminate all processes in this family