ipmininet.router.config.base module

This modules provides a config object for a router, that is able to provide configurations for a set of routing daemons. It also defines the base class for a daemon, as well as a minimalistic configuration for a router.

class ipmininet.router.config.base.BasicRouterConfig(node, daemons=(), additional_daemons=(), *args, **kwargs)

Bases: ipmininet.router.config.base.RouterConfig

A basic router that will run an OSPF daemon

A simple router made of at least an OSPF daemon

Parameters:additional_daemons – Other daemons that should be used
class ipmininet.router.config.base.Daemon(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: object

This class serves as base for routing daemons

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
DEPENDS = ()
KILL_PATTERNS = ()
NAME = None
PRIO = 10
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
cfg_filename

Return the main filename in which this daemon config should be stored

cfg_filenames

Return the list of filenames in which this daemon config should be stored

cleanup()

Cleanup the files belonging to this daemon

dry_run

The startup line to use to check that the daemon is well-configured

classmethod get_config(topo, router, **kwargs)

Returns a config object for the daemon if any

has_started()

Return whether this daemon has started or not

options

Get the options ConfigDict for this daemon

render(cfg, **kwargs)

Render the configuration content for each config file of this daemon

Parameters:
  • cfg – The global config for the node
  • kwargs – Additional keywords args. will be passed directly to the template
set_defaults(defaults)

Update defaults to contain the defaults specific to this daemon

startup_line

Return the corresponding startup_line for this daemon

template_filenames
write(cfg)

Write down the configuration files for this daemon

Parameters:cfg – The configuration string
class ipmininet.router.config.base.NodeConfig(node, daemons=(), sysctl=None, *args, **kwargs)

Bases: object

This class manages a set of daemons, and generates the global configuration for a node

Initialize our config builder

Parameters:
  • node – The node for which this object will build configurations
  • daemons – an iterable of active routing daemons for this node
  • sysctl – A dictionnary of sysctl to set for this node. By default, it enables IPv4/IPv6 forwarding on all interfaces.
build()

Build the configuration for each daemon, then write the configuration files

cleanup()

Cleanup all temporary files for the daemons

daemon(key)

Return the Daemon object in this config for the given key

Parameters:key – the daemon name or a daemon class or instance
Returns:the Daemon object
Raises:KeyError – if not found
daemons
post_register_daemons()

Method called after all daemon classes were instantiated

register_daemon(cls, **daemon_opts)

Add a new daemon to this configuration

Parameters:
  • cls – Daemon class or object, or a 2-tuple (Daemon, dict)
  • daemon_opts – Options to set on the daemons
sysctl

Return an list of all sysctl to set on this node

class ipmininet.router.config.base.RouterConfig(node, sysctl=None, *args, **kwargs)

Bases: ipmininet.router.config.base.NodeConfig

compute_routerid()

Computes the default router id for all daemons. If a router ids were explicitly set for some of its daemons, the router id set to the daemon with the highest priority is chosen as the global router id. Otherwise if it has IPv4 addresses, it returns the most-visible one among its router interfaces. If both conditions are wrong, it generates a unique router id.

static incr_last_routerid()
post_register_daemons()

Method called after all daemon classes were instantiated

class ipmininet.router.config.base.RouterDaemon(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.base.Daemon

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
set_defaults(defaults)
Parameters:
  • logfile – the path to the logfile for the daemon
  • routerid – the router id for this daemon