* After running stop Mininet with: tgen.stop_topology()
"""
+import configparser
import grp
import inspect
import json
import platform
import pwd
import re
+import shlex
import subprocess
import sys
from collections import OrderedDict
-if sys.version_info[0] > 2:
- import configparser
-else:
- import ConfigParser as configparser
-
import lib.topolog as topolog
from lib.micronet import Commander
from lib.micronet_compat import Mininet
from lib.topolog import logger
-from lib.topotest import g_extra_config
+from munet.testing.util import pause_test
from lib import topotest
self._load_config()
# Create new log directory
- self.logdir = topotest.get_logs_path(g_extra_config["rundir"])
+ self.logdir = topotest.get_logs_path(topotest.g_pytest_config.option.rundir)
subprocess.check_call(
"mkdir -p {0} && chmod 1777 {0}".format(self.logdir), shell=True
)
# Mininet(Micronet) to build the actual topology.
assert not inspect.isclass(topodef)
- self.net = Mininet()
+ self.net = Mininet(rundir=self.logdir, pytestconfig=topotest.g_pytest_config)
# Adjust the parent namespace
topotest.fix_netns_limits(self.net)
self.add_topology_from_dict(topodef)
def add_topology_from_dict(self, topodef):
-
keylist = (
topodef.keys()
if isinstance(topodef, OrderedDict)
first is a simple kill with no sleep, the second will sleep if not
killed and try with a different signal.
"""
+ pause = bool(self.net.cfgopt.get_option("--pause-at-end"))
+ pause = pause or bool(self.net.cfgopt.get_option("--pause"))
+ if pause:
+ try:
+ pause_test("Before MUNET delete")
+ except KeyboardInterrupt:
+ print("^C...continuing")
+ except Exception as error:
+ self.logger.error("\n...continuing after error: %s", error)
+
logger.info("stopping topology: {}".format(self.modname))
+
errors = ""
for gear in self.gears.values():
errors += gear.stop()
"""
super(TopoRouter, self).__init__(tgen, name, **params)
self.routertype = params.get("routertype", "frr")
- if "privateDirs" not in params:
- params["privateDirs"] = self.PRIVATE_DIRS
+ if "private_mounts" not in params:
+ params["private_mounts"] = self.PRIVATE_DIRS
# Propagate the router log directory
logfile = self._setup_tmpdir()
"conf t",
"log file {}.log debug".format(daemon),
"log commands",
- "log timestamp precision 3",
+ "log timestamp precision 6",
]
),
daemon=daemon,
"conf t",
"log file {}.log debug".format(daemon),
"log commands",
- "log timestamp precision 3",
+ "log timestamp precision 6",
]
),
daemon=daemon,
if daemon is not None:
dparam += "-d {}".format(daemon)
- vtysh_command = 'vtysh {} -c "{}" 2>/dev/null'.format(dparam, command)
+ vtysh_command = "vtysh {} -c {} 2>/dev/null".format(
+ dparam, shlex.quote(command)
+ )
- self.logger.debug('vtysh command => "{}"'.format(command))
+ self.logger.debug("vtysh command => {}".format(shlex.quote(command)))
output = self.run(vtysh_command)
dbgout = output.strip()
* `ip`: the IP address (string) for the host interface
* `defaultRoute`: the default route that will be installed
(e.g. 'via 10.0.0.1')
- * `privateDirs`: directories that will be mounted on a different domain
+ * `private_mounts`: directories that will be mounted on a different domain
(e.g. '/etc/important_dir').
"""
super(TopoHost, self).__init__(tgen, name, **params)
def __str__(self):
gear = super(TopoHost, self).__str__()
- gear += ' TopoHost<ip="{}",defaultRoute="{}",privateDirs="{}">'.format(
+ gear += ' TopoHost<ip="{}",defaultRoute="{}",private_mounts="{}">'.format(
self.params["ip"],
self.params["defaultRoute"],
- str(self.params["privateDirs"]),
+ str(self.params["private_mounts"]),
)
return gear
(e.g. 'via 10.0.0.1')
Note: the different between a host and a ExaBGP peer is that this class
- has a privateDirs already defined and contains functions to handle ExaBGP
- things.
+ has a private_mounts already defined and contains functions to handle
+ ExaBGP things.
"""
- params["privateDirs"] = self.PRIVATE_DIRS
+ params["private_mounts"] = self.PRIVATE_DIRS
super(TopoExaBGP, self).__init__(tgen, name, **params)
def __str__(self):
# Diagnostic function
#
+
# Disable linter branch warning. It is expected to have these here.
# pylint: disable=R0912
def diagnose_env_linux(rundir):