X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Ftopology.py;h=103416078a1b21e032deefbac80d779114e5cddb;hp=6a7ea798ccc3d835d5eb59f50be92603c506be2d;hb=8f285166faf13156a4f7c70adac9a7e20549268f;hpb=da23519d72dc9415b112f7bab1fd3617750fa79e diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py index 6a7ea798cc..103416078a 100644 --- a/resources/libraries/python/topology.py +++ b/resources/libraries/python/topology.py @@ -195,7 +195,7 @@ class Topology(object): interface_dict = {} list_mac_address = self.convert_mac_to_number_list(mac_address) - logger.trace(list_mac_address.__str__()) + logger.trace(str(list_mac_address)) for interface in interfaces_list: # TODO: create vat json integrity checking and move there if "l2_address" not in interface: @@ -254,6 +254,9 @@ class Topology(object): if_mac = ifc['mac_address'] interface_dict = self._extract_vpp_interface_by_mac(interface_list, if_mac) + if not interface_dict: + raise Exception('Interface {0} not found by MAC {1}'. + format(ifc, if_mac)) ifc['name'] = interface_dict["interface_name"] ifc['vpp_sw_index'] = interface_dict["sw_if_index"] @@ -647,3 +650,20 @@ class Topology(object): 'DUT1_BD_LINKS': dut1_bd_links, 'DUT2_BD_LINKS': dut2_bd_links} return topology_links + + @staticmethod + def is_tg_node(node): + """Find out whether the node is TG + + :param node: node to examine + :return: True if node is type of TG; False otherwise + """ + return node['type'] == NodeType.TG + + @staticmethod + def get_node_hostname(node): + """ + :param node: node dictionary + :return: host name as 'str' type + """ + return node['host'] \ No newline at end of file