X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FInterfaceUtil.py;h=a68b9211467bcb3bbfd1b51b312cd89247b92e02;hp=795bb52933994c45450c9ca126ed7da0fa7d29da;hb=2cc797fa23da02eefa19637521098ec41622189b;hpb=9a261ea61549fc6a5c23369d2e236b002dc35038 diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 795bb52933..a68b921146 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -220,6 +220,29 @@ class InterfaceUtil(object): return dict() return data + @staticmethod + def vpp_get_interface_name(node, sw_if_index): + """Get interface name for the given SW interface index from actual + interface dump. + + :param node: VPP node to get interface data from. + :param sw_if_index: SW interface index of the specific interface. + :type node: dict + :type sw_if_index: int + :returns: Name of the given interface. + :rtype: str + """ + + if_data = InterfaceUtil.vpp_get_interface_data(node, sw_if_index) + if if_data['sup_sw_if_index'] != if_data['sw_if_index']: + if_data = InterfaceUtil.vpp_get_interface_data( + node, if_data['sup_sw_if_index']) + try: + if_name = if_data["interface_name"] + except KeyError: + if_name = None + return if_name + @staticmethod def vpp_get_interface_mac(node, interface=None): """Get MAC address for the given interface from actual interface dump.