diff --git a/test/env b/test/env index 0e097f0e4..21c2da6d3 100755 --- a/test/env +++ b/test/env @@ -181,8 +181,8 @@ if [ "$containerize" ]; then --cap-add=NET_ADMIN \ --device=/dev/net/tun \ --env PYTHONHASHSEED=${PYTHONHASHSEED:-$(shuf -i 0-$(((1 << 32) - 1)) -n 1)} \ - --env FORCE_PROTOCOL=${FORCE_PROTOCOL} \ --env VIRTUAL_ENV_DISABLE_PROMPT=yes \ + --env INFAMY_EXTRA_ARGS="$INFAMY_EXTRA_ARGS" \ --env PROMPT_DIRTRIM="$ixdir" \ --env PS1="$(build_ps1)" \ --expose 9001-9010 --publish-all \ @@ -220,5 +220,8 @@ INFAMY_ARGS="$INFAMY_ARGS -y $envdir/yangdir" start_topology "$qenethdir" "$files" [ "$topology" ] && INFAMY_ARGS="$INFAMY_ARGS $topology" export INFAMY_ARGS +if [ -n "$INFAMY_EXTRA_ARGS" ]; then + exec "$@" -o="$INFAMY_EXTRA_ARGS" +fi exec "$@" diff --git a/test/infamy/env.py b/test/infamy/env.py index 0a199b7cd..d3e8b9dd2 100644 --- a/test/infamy/env.py +++ b/test/infamy/env.py @@ -5,8 +5,6 @@ import shlex import sys import random -import hashlib -import struct from . import neigh, netconf, restconf, ssh, tap, topology @@ -24,6 +22,7 @@ def __init__(self, ltop): self.add_argument("-l", "--logical-topology", dest="ltop", default=ltop) self.add_argument("-p", "--package", default=None) self.add_argument("-y", "--yangdir", default=None) + self.add_argument("-t", "--transport", default=None) self.add_argument("ptop", nargs=1, metavar="topology") @@ -64,7 +63,7 @@ def attr(self, name, default=None): def get_password(self, node): return self.ptop.get_password(node) - def attach(self, node, port, protocol = None, factory_default=True): + def attach(self, node, port, protocol=None, factory_default=True): if self.ltop: mapping = self.ltop.mapping[node] node, port = self.ltop.xlate(node, port) @@ -72,22 +71,12 @@ def attach(self, node, port, protocol = None, factory_default=True): mapping = None if protocol is None: - if "FORCE_PROTOCOL" in os.environ and os.environ["FORCE_PROTOCOL"] != "": - protocol=os.environ["FORCE_PROTOCOL"] - elif "PYTHONHASHSEED" in os.environ: - file_name = f"{sys.argv[0]}-{os.environ['PYTHONHASHSEED']}" - hash_object = hashlib.md5(file_name.encode()) - hash_digest = hash_object.digest() - - seed = struct.unpack('i', hash_digest[:4])[0] - random.seed(seed) - protocols=["restconf", "netconf"] - random.shuffle(protocols) - protocol=protocols[0] + if not self.args.transport is None: + protocol=self.args.transport else: - protocols=["restconf", "netconf"] - random.shuffle(protocols) - protocol=protocols[0] + random.seed(f"{sys.argv[0]}-{os.environ.get('PYTHONHASHSEED',0)}") + protocol = random.choice(["netconf", "restconf"]) + password=self.get_password(node) ctrl = self.ptop.get_ctrl() cport, _ = self.ptop.get_mgmt_link(ctrl, node) diff --git a/test/infamy/netconf.py b/test/infamy/netconf.py index 8699cd4b3..553fbe083 100644 --- a/test/infamy/netconf.py +++ b/test/infamy/netconf.py @@ -401,7 +401,7 @@ def get_iface(self, iface): if interface is None: return None - # This really not required, it is due a bug in rousette. + # Restconf (rousette) address by id and netconf (netopper2) address by name return interface[iface] def delete_xpath(self, xpath): diff --git a/test/infamy/restconf.py b/test/infamy/restconf.py index 0e083f1e6..0b27f72ad 100644 --- a/test/infamy/restconf.py +++ b/test/infamy/restconf.py @@ -290,7 +290,7 @@ def get_iface(self, iface): if interface is None: return None - # This is a bug in rousette, should be able to use the same code as NETCONF + # Restconf (rousette) address by id and netconf (netopper2) address by name return interface[0] def delete_xpath(self, xpath):