+ Namespaces.__namespaces.append(namespace)
+
+ @staticmethod
+ def delete_namespace(node, namespace):
+ """Delete namespace from the node and list.
+
+ :param node: Where to delete namespace.
+ :param namespace: Name for namespace.
+ :param delete_before_create: Delete namespace prior to create
+ :type node: dict
+ :type namespace: str
+ :type delete_before_create: bool
+ """
+ cmd_timeout = 5
+ cmd = f"ip netns delete {namespace}"
+ (ret_code, _, delete_errmsg) = \
+ exec_cmd(node, cmd, timeout=cmd_timeout, sudo=True)
+ if ret_code != 0:
+ cmd = f"ip netns list {namespace}"
+ (stdout, _) = \
+ exec_cmd_no_error(node, cmd, timeout=cmd_timeout, sudo=True)
+ if stdout == namespace:
+ raise RuntimeError(f"Could not delete namespace "
+ f"({namespace}): {delete_errmsg}")
+ try:
+ Namespaces.__namespaces.remove(namespace)
+ except ValueError:
+ pass