aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2020-10-20 14:37:33 +0000
committerpmikus <pmikus@cisco.com>2020-10-20 14:37:33 +0000
commitede9f62894bd29194ba4eca5de4e226cd447a9da (patch)
tree2e71a4c4f369cedc4c4a503453b2d92cc20e31df /resources/libraries/python
parentd65e6247bf53ec070683209d8a115b37e3933127 (diff)
FIX: Namespace deletion
+ Not sure who was doing code. + Set interface up should have namespace version Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: I1103cddb9dd11e25a8ab0ce3f5126b2db9444749
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/IPUtil.py12
-rw-r--r--resources/libraries/python/Namespaces.py5
2 files changed, 13 insertions, 4 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py
index 10a231f9df..552ba27d61 100644
--- a/resources/libraries/python/IPUtil.py
+++ b/resources/libraries/python/IPUtil.py
@@ -326,18 +326,24 @@ class IPUtil:
return None
@staticmethod
- def set_linux_interface_up(node, interface):
+ def set_linux_interface_up(
+ node, interface, namespace=None):
"""Set the specified interface up.
-
:param node: VPP/TG node.
:param interface: Interface in namespace.
+ :param namespace: Execute command in namespace. Optional
:type node: dict
:type interface: str
+ :type namespace: str
:raises RuntimeError: If the interface could not be set up.
"""
- cmd = f"ip link set {interface} up"
+ if namespace is not None:
+ cmd = f"ip netns exec {namespace} ip link set dev {interface} up"
+ else:
+ cmd = f"ip link set dev {interface} up"
exec_cmd_no_error(node, cmd, timeout=30, sudo=True)
+
@staticmethod
def set_linux_interface_ip(
node, interface, ip_addr, prefix, namespace=None):
diff --git a/resources/libraries/python/Namespaces.py b/resources/libraries/python/Namespaces.py
index 2bdcbcb324..4bea8b5575 100644
--- a/resources/libraries/python/Namespaces.py
+++ b/resources/libraries/python/Namespaces.py
@@ -13,6 +13,8 @@
"""Linux namespace utilities library."""
+from copy import deepcopy
+
from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd
@@ -145,5 +147,6 @@ class Namespaces:
Namespaces.delete_namespace(node, namespace)
return
- for namespace_name in Namespaces.__namespaces:
+ namespace_copy = deepcopy(Namespaces.__namespaces)
+ for namespace_name in namespace_copy:
Namespaces.delete_namespace(node, namespace_name)