aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/topology.py
diff options
context:
space:
mode:
authorMatej Klotton <mklotton@cisco.com>2016-03-11 13:56:39 +0100
committerStefan Kobza <skobza@cisco.com>2016-04-13 16:09:31 +0000
commit6d9fe9bb4bd353b1d4fec3b2569bcd743f87fc4a (patch)
tree7a21e9072114ba6670fab95421ded8796335c1c4 /resources/libraries/python/topology.py
parent5a2fd159dce96a70f2e5157314391aceb6d80197 (diff)
VXLAN test with dot1q tagging.
Change-Id: I3dbd12983736e338d757c580570d91680aedd83f Signed-off-by: Matej Klotton <mklotton@cisco.com>
Diffstat (limited to 'resources/libraries/python/topology.py')
-rw-r--r--resources/libraries/python/topology.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py
index d04d584623..0f26d2c6e9 100644
--- a/resources/libraries/python/topology.py
+++ b/resources/libraries/python/topology.py
@@ -164,20 +164,22 @@ class Topology(object):
@staticmethod
def get_interface_sw_index(node, interface):
- """Get VPP sw_index for the interface.
+ """Get VPP sw_if_index for the interface.
- :param node: Node to get interface sw_index on.
- :param interface: Interface name.
+ :param node: Node to get interface sw_if_index on.
+ :param interface: Interface identifier.
:type node: dict
- :type interface: str
- :return: Return sw_index or None if not found.
+ :type interface: str or int
+ :return: Return sw_if_index or None if not found.
"""
- for port in node['interfaces'].values():
- port_name = port.get('name')
- if port_name == interface:
- return port.get('vpp_sw_index')
-
- return None
+ try:
+ return int(interface)
+ except ValueError:
+ for port in node['interfaces'].values():
+ port_name = port.get('name')
+ if port_name == interface:
+ return port.get('vpp_sw_index')
+ return None
@staticmethod
def get_interface_mtu(node, interface):