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 routing 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, **kwargs)¶ Bases:
object
This class serves as base for routing daemons
Parameters: - node – The node for which we build the config
- 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 filename 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
-
has_started
()¶ Return whether this daemon has started or not
-
options
¶ Get the options ConfigDict for this daemon
-
render
(cfg, **kwargs)¶ Render the configuration file for 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_filename
¶
-
write
(cfg)¶ Write down the configuration for this daemon
Parameters: cfg – The configuration string
-
class
ipmininet.router.config.base.
RouterConfig
(node, daemons=(), sysctl=None, *args, **kwargs)¶ Bases:
object
This class manages a set of daemons, and generates the global configuration for a router
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
-
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.
-
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
¶
-
static
incr_last_routerid
()¶
-
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