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: Router, daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), additional_daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), *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.
BorderRouterConfig
(node: Router, daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), additional_daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), *args, **kwargs)¶ Bases:
ipmininet.router.config.base.BasicRouterConfig
A router config that will run both OSPF and BGP, and redistribute all connected router into BGP.
A simple router made of at least an OSPF daemon and a BGP daemon
Parameters: additional_daemons – Other daemons that should be used
-
class
ipmininet.router.config.base.
Daemon
(node: IPNode, template_lookup: mako.lookup.TemplateLookup = <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
() → ipmininet.router.config.utils.ConfigDict¶ 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: IPTopo, node: NodeDescription, **kwargs)¶ Returns a config object for the daemon if any
-
has_started
(node_exec: ProcessHelper = None) → bool¶ Return whether this daemon has started or not :param node_exec:
-
logdir
¶
-
options
¶ Get the options ConfigDict for this daemon
-
render
(cfg, **kwargs) → Dict[str, str]¶ 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: Dict[str, str])¶ Write down the configuration files for this daemon
Parameters: cfg – The configuration string for each filename
-
class
ipmininet.router.config.base.
NodeConfig
(node: IPNode, daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), sysctl: Optional[Dict[str, Union[str, int]]] = 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 dictionary of sysctl to set for this node. By default, it enables IPv4/IPv6 forwarding on all interfaces.
-
add_private_fs_path
(loc: Sequence[Union[str, Tuple[str, str]]] = ())¶
-
build
()¶ Build the configuration for each daemon, then write the configuration files
-
build_host_file
(filename: str)¶
-
cleanup
()¶ Cleanup all temporary files for the daemons
-
daemon
(key: Union[str, Daemon, Type[Daemon]]) → ipmininet.router.config.base.Daemon¶ 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: Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]], **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.
OpenrRouterConfig
(node: OpenrRouter, daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), additional_daemons: Iterable[Union[Daemon, Type[Daemon], Tuple[Union[Daemon, Type[Daemon]], Dict[KT, VT]]]] = (), *args, **kwargs)¶ Bases:
ipmininet.router.config.base.RouterConfig
A basic router that will run an OpenR daemon
A simple router made of at least an OpenR daemon
Parameters: additional_daemons – Other daemons that should be used
-
class
ipmininet.router.config.base.
RouterConfig
(node: Router, sysctl=None, *args, **kwargs)¶ Bases:
ipmininet.router.config.base.NodeConfig
-
compute_routerid
() → str¶ 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: IPNode, template_lookup: mako.lookup.TemplateLookup = <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