1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Defines nodes and topology structure."""
18 from collections import Counter
22 from robot.api import logger
23 from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
24 from robot.api.deco import keyword
26 __all__ = ["DICT__nodes", 'Topology', 'NodeType', 'SocketType']
29 def load_topo_from_yaml():
30 """Load topology from file defined in "${TOPOLOGY_PATH}" variable.
32 :returns: Nodes from loaded topology.
35 topo_path = BuiltIn().get_variable_value("${TOPOLOGY_PATH}")
36 except RobotNotRunningError:
39 with open(topo_path) as work_file:
40 return load(work_file.read())['nodes']
43 # pylint: disable=invalid-name
45 class NodeType(object):
46 """Defines node types used in topology dictionaries."""
47 # Device Under Test (this node has VPP running on it)
49 # Traffic Generator (this node has traffic generator on it)
51 # Virtual Machine (this node running on DUT node)
55 class NodeSubTypeTG(object):
56 """Defines node sub-type TG - traffic generator."""
57 # T-Rex traffic generator
64 class SocketType(object):
65 """Defines socket types used in topology dictionaries."""
68 # VPP PAPI Stats (legacy option until stats are migrated to Socket PAPI)
71 DICT__nodes = load_topo_from_yaml()
74 class Topology(object):
75 """Topology data manipulation and extraction methods.
77 Defines methods used for manipulation and extraction of data from
80 "Active topology" contains initially data from the topology file and can be
81 extended with additional data from the DUTs like internal interface indexes
82 or names. Additional data which can be filled to the active topology are
84 - additional internal representation (index, name, ...)
85 - operational data (dynamic ports)
87 To access the port data it is recommended to use a port key because the key
88 does not rely on the data retrieved from nodes, this allows to call most of
89 the methods without having filled active topology with internal nodes data.
92 def add_node_item(self, node, value, path):
93 """Add item to topology node.
95 :param node: Topology node.
96 :param value: Value to insert.
97 :param path: Path where to insert item.
103 node[path[0]] = value
105 if path[0] not in node:
107 elif isinstance(node[path[0]], str):
108 node[path[0]] = {} if node[path[0]] == '' \
109 else {node[path[0]]: ''}
110 self.add_node_item(node[path[0]], value, path[1:])
113 def add_new_port(node, ptype):
114 """Add new port to the node to active topology.
116 :param node: Node to add new port on.
117 :param ptype: Port type, used as key prefix.
120 :returns: Port key or None
121 :rtype: string or None
125 for i in range(1, max_ports):
126 if node['interfaces'].get(str(ptype) + str(i)) is None:
127 iface = str(ptype) + str(i)
128 node['interfaces'][iface] = dict()
133 def remove_port(node, iface_key):
134 """Remove required port from active topology.
136 :param node: Node to remove port on.
137 :param: iface_key: Topology key of the interface.
143 node['interfaces'].pop(iface_key)
148 def remove_all_ports(node, ptype):
149 """Remove all ports with ptype as prefix.
151 :param node: Node to remove ports on.
152 :param: ptype: Port type, used as key prefix.
157 for if_key in list(node['interfaces']):
158 if if_key.startswith(str(ptype)):
159 node['interfaces'].pop(if_key)
162 def remove_all_added_ports_on_all_duts_from_topology(nodes):
163 """Remove all added ports on all DUT nodes in the topology.
165 :param nodes: Nodes in the topology.
169 port_types = ('subinterface', 'vlan_subif', 'memif', 'tap', 'vhost',
170 'loopback', 'gre_tunnel', 'vxlan_tunnel', 'eth_bond',
173 for node_data in nodes.values():
174 if node_data['type'] == NodeType.DUT:
175 for ptype in port_types:
176 Topology.remove_all_ports(node_data, ptype)
179 def remove_all_vif_ports(node):
180 """Remove all Virtual Interfaces on DUT node.
182 :param node: Node to remove VIF ports on.
186 reg_ex = re.compile(r'port\d+_vif\d+')
187 for if_key in list(node['interfaces']):
188 if re.match(reg_ex, if_key):
189 node['interfaces'].pop(if_key)
192 def remove_all_added_vif_ports_on_all_duts_from_topology(nodes):
193 """Remove all added Virtual Interfaces on all DUT nodes in
196 :param nodes: Nodes in the topology.
200 for node_data in nodes.values():
201 if node_data['type'] == NodeType.DUT:
202 Topology.remove_all_vif_ports(node_data)
205 def update_interface_sw_if_index(node, iface_key, sw_if_index):
206 """Update sw_if_index on the interface from the node.
208 :param node: Node to update sw_if_index on.
209 :param iface_key: Topology key of the interface.
210 :param sw_if_index: Internal index to store.
213 :type sw_if_index: int
215 node['interfaces'][iface_key]['vpp_sw_index'] = int(sw_if_index)
218 def update_interface_name(node, iface_key, name):
219 """Update name on the interface from the node.
221 :param node: Node to update name on.
222 :param iface_key: Topology key of the interface.
223 :param name: Interface name to store.
228 node['interfaces'][iface_key]['name'] = str(name)
231 def update_interface_mac_address(node, iface_key, mac_address):
232 """Update mac_address on the interface from the node.
234 :param node: Node to update MAC on.
235 :param iface_key: Topology key of the interface.
236 :param mac_address: MAC address.
239 :type mac_address: str
241 node['interfaces'][iface_key]['mac_address'] = str(mac_address)
244 def update_interface_pci_address(node, iface_key, pci_address):
245 """Update pci_address on the interface from the node.
247 :param node: Node to update PCI on.
248 :param iface_key: Topology key of the interface.
249 :param pci_address: PCI address.
252 :type pci_address: str
254 node['interfaces'][iface_key]['pci_address'] = str(pci_address)
257 def update_interface_vlan(node, iface_key, vlan):
258 """Update VLAN on the interface from the node.
260 :param node: Node to update VLAN on.
261 :param iface_key: Topology key of the interface.
262 :param vlan: VLAN ID.
267 node['interfaces'][iface_key]['vlan'] = int(vlan)
270 def update_interface_vhost_socket(node, iface_key, vhost_socket):
271 """Update vhost socket name on the interface from the node.
273 :param node: Node to update socket name on.
274 :param iface_key: Topology key of the interface.
275 :param vhost_socket: Path to named socket on node.
278 :type vhost_socket: str
280 node['interfaces'][iface_key]['vhost_socket'] = str(vhost_socket)
283 def update_interface_memif_socket(node, iface_key, memif_socket):
284 """Update memif socket name on the interface from the node.
286 :param node: Node to update socket name on.
287 :param iface_key: Topology key of the interface.
288 :param memif_socket: Path to named socket on node.
291 :type memif_socket: str
293 node['interfaces'][iface_key]['memif_socket'] = str(memif_socket)
296 def update_interface_memif_id(node, iface_key, memif_id):
297 """Update memif ID on the interface from the node.
299 :param node: Node to update memif ID on.
300 :param iface_key: Topology key of the interface.
301 :param memif_id: Memif interface ID.
306 node['interfaces'][iface_key]['memif_id'] = str(memif_id)
309 def update_interface_memif_role(node, iface_key, memif_role):
310 """Update memif role on the interface from the node.
312 :param node: Node to update memif role on.
313 :param iface_key: Topology key of the interface.
314 :param memif_role: Memif role.
317 :type memif_role: str
319 node['interfaces'][iface_key]['memif_role'] = str(memif_role)
322 def update_interface_tap_dev_name(node, iface_key, dev_name):
323 """Update device name on the tap interface from the node.
325 :param node: Node to update tap device name on.
326 :param iface_key: Topology key of the interface.
327 :param dev_name: Device name of the tap interface.
333 node['interfaces'][iface_key]['dev_name'] = str(dev_name)
336 def get_node_by_hostname(nodes, hostname):
337 """Get node from nodes of the topology by hostname.
339 :param nodes: Nodes of the test topology.
340 :param hostname: Host name.
343 :returns: Node dictionary or None if not found.
345 for node in nodes.values():
346 if node['host'] == hostname:
352 def get_links(nodes):
353 """Get list of links(networks) in the topology.
355 :param nodes: Nodes of the test topology.
357 :returns: Links in the topology.
362 for node in nodes.values():
363 for interface in node['interfaces'].values():
364 link = interface.get('link')
366 if link not in links:
372 def _get_interface_by_key_value(node, key, value):
373 """Return node interface key from topology file
374 according to key and value.
376 :param node: The node dictionary.
377 :param key: Key by which to select the interface.
378 :param value: Value that should be found using the key.
382 :returns: Interface key from topology file
385 interfaces = node['interfaces']
387 for if_key, if_val in interfaces.iteritems():
388 k_val = if_val.get(key)
389 if k_val is not None:
396 def get_interface_by_name(node, iface_name):
397 """Return interface key based on name from DUT/TG.
399 This method returns interface key based on interface name
400 retrieved from the DUT, or TG.
402 :param node: The node topology dictionary.
403 :param iface_name: Interface name (string form).
405 :type iface_name: string
406 :returns: Interface key.
409 return Topology._get_interface_by_key_value(node, "name", iface_name)
412 def get_interface_by_link_name(node, link_name):
413 """Return interface key of link on node.
415 This method returns the interface name associated with a given link
418 :param node: The node topology dictionary.
419 :param link_name: Name of the link that a interface is connected to.
421 :type link_name: string
422 :returns: Interface key of the interface connected to the given link.
425 return Topology._get_interface_by_key_value(node, "link", link_name)
427 def get_interfaces_by_link_names(self, node, link_names):
428 """Return dictionary of dictionaries {"interfaceN", interface name}.
430 This method returns the interface names associated with given links
433 :param node: The node topology directory.
434 :param link_names: List of names of the link that a interface is
437 :type link_names: list
438 :returns: Dictionary of interface names that are connected to the given
443 interface_key_tpl = "interface{}"
445 for link_name in link_names:
446 interface = self.get_interface_by_link_name(node, link_name)
447 interface_name = self.get_interface_name(node, interface)
448 interface_key = interface_key_tpl.format(str(interface_number))
449 retval[interface_key] = interface_name
450 interface_number += 1
454 def get_interface_by_sw_index(node, sw_if_index):
455 """Return interface name of link on node.
457 This method returns the interface name associated with a software
458 interface index assigned to the interface by vpp for a given node.
460 :param node: The node topology dictionary.
461 :param sw_if_index: sw_if_index of the link that a interface is
464 :type sw_if_index: int
465 :returns: Interface name of the interface connected to the given link.
468 return Topology._get_interface_by_key_value(node, "vpp_sw_index",
472 def get_interface_sw_index(node, iface_key):
473 """Get VPP sw_if_index for the interface using interface key.
475 :param node: Node to get interface sw_if_index on.
476 :param iface_key: Interface key from topology file, or sw_if_index.
478 :type iface_key: str/int
479 :returns: Return sw_if_index or None if not found.
483 if isinstance(iface_key, basestring):
484 return node['interfaces'][iface_key].get('vpp_sw_index')
485 # TODO: use only iface_key, do not use integer
486 return int(iface_key)
487 except (KeyError, ValueError):
491 def get_interface_sw_index_by_name(node, iface_name):
492 """Get VPP sw_if_index for the interface using interface name.
494 :param node: Node to get interface sw_if_index on.
495 :param iface_name: Interface name.
497 :type iface_name: str
498 :returns: Return sw_if_index or None if not found.
499 :raises TypeError: If provided interface name is not a string.
502 if not isinstance(iface_name, basestring):
503 raise TypeError("Interface name must be a string.")
504 iface_key = Topology.get_interface_by_name(node, iface_name)
505 return node['interfaces'][iface_key].get('vpp_sw_index')
506 except (KeyError, ValueError):
510 def get_interface_mtu(node, iface_key):
511 """Get interface MTU.
513 Returns physical layer MTU (max. size of Ethernet frame).
514 :param node: Node to get interface MTU on.
515 :param iface_key: Interface key from topology file.
518 :returns: MTU or None if not found.
522 return node['interfaces'][iface_key].get('mtu')
527 def get_interface_name(node, iface_key):
528 """Get interface name (retrieved from DUT/TG).
530 Returns name in string format, retrieved from the node.
531 :param node: Node to get interface name on.
532 :param iface_key: Interface key from topology file.
535 :returns: Interface name or None if not found.
539 return node['interfaces'][iface_key].get('name')
544 def convert_interface_reference_to_key(node, interface):
545 """Takes interface reference in any format
546 (name, link name, interface key or sw_if_index)
547 and converts to interface key using Topology methods.
549 :param node: Node in topology.
550 :param interface: Name, sw_if_index, link name or key of an interface
553 :type interface: str or int
555 :returns: Interface key.
558 :raises TypeError: If provided with invalid interface argument.
559 :raises RuntimeError: If the interface does not exist in topology.
562 if isinstance(interface, int):
563 key = Topology.get_interface_by_sw_index(node, interface)
565 raise RuntimeError("Interface with sw_if_index={0} does not "
566 "exist in topology.".format(interface))
567 elif interface in Topology.get_node_interfaces(node):
569 elif interface in Topology.get_links({"dut": node}):
570 key = Topology.get_interface_by_link_name(node, interface)
571 elif isinstance(interface, basestring):
572 key = Topology.get_interface_by_name(node, interface)
574 raise RuntimeError("Interface with key, name or link name "
575 "\"{0}\" does not exist in topology."
578 raise TypeError("Type of interface argument must be integer"
583 def convert_interface_reference(node, interface, wanted_format):
584 """Takes interface reference in any format
585 (name, link name, topology key or sw_if_index) and returns
586 its equivalent in the desired format.
588 :param node: Node in topology.
589 :param interface: Name, sw_if_index, link name or key of an interface
591 :param wanted_format: Format of return value wanted.
592 Valid options are: sw_if_index, key, name.
594 :type interface: str or int
595 :type wanted_format: str
596 :returns: Interface name, interface key or sw_if_index.
598 :raises TypeError, ValueError: If provided with invalid arguments.
599 :raises RuntimeError: If the interface does not exist in topology.
602 key = Topology.convert_interface_reference_to_key(node, interface)
605 "key": lambda x, y: y,
606 "name": Topology.get_interface_name,
607 "sw_if_index": Topology.get_interface_sw_index
611 return conversions[wanted_format](node, key)
613 raise ValueError("Unrecognized return value wanted: {0}."
614 "Valid options are key, name, sw_if_index"
615 .format(wanted_format))
618 def get_interface_numa_node(node, iface_key):
619 """Get interface numa node.
621 Returns physical relation to numa node, numa_id.
623 :param node: Node to get numa id on.
624 :param iface_key: Interface key from topology file.
627 :returns: numa node id, None if not available.
631 return node['interfaces'][iface_key].get('numa_node')
636 def get_interfaces_numa_node(node, *iface_keys):
637 """Get numa node on which are located most of the interfaces.
639 Return numa node with highest count of interfaces provided as arguments.
640 Return 0 if the interface does not have numa_node information available.
641 If all interfaces have unknown location (-1), then return 0.
642 If most of interfaces have unknown location (-1), but there are
643 some interfaces with known location, then return the second most
644 location of the provided interfaces.
646 :param node: Node from DICT__nodes.
647 :param iface_keys: Interface keys for lookup.
649 :type iface_keys: strings
650 :returns: Numa node of most given interfaces or 0.
654 for if_key in iface_keys:
656 numa_list.append(node['interfaces'][if_key].get('numa_node'))
660 numa_cnt_mc = Counter(numa_list).most_common()
662 if numa_cnt_mc and numa_cnt_mc[0][0] != -1:
663 return numa_cnt_mc[0][0]
664 if len(numa_cnt_mc) > 1 and numa_cnt_mc[0][0] == -1:
665 return numa_cnt_mc[1][0]
669 def get_interface_mac(node, iface_key):
670 """Get MAC address for the interface.
672 :param node: Node to get interface mac on.
673 :param iface_key: Interface key from topology file.
676 :returns: Return MAC or None if not found.
679 return node['interfaces'][iface_key].get('mac_address')
684 def get_interface_ip4(node, iface_key):
685 """Get IP4 address for the interface.
687 :param node: Node to get interface mac on.
688 :param iface_key: Interface key from topology file.
691 :returns: Return IP4 or None if not found.
694 return node['interfaces'][iface_key].get('ip4_address', None)
699 def get_adjacent_node_and_interface(nodes_info, node, iface_key):
700 """Get node and interface adjacent to specified interface
703 :param nodes_info: Dictionary containing information on all nodes
705 :param node: Node that contains specified interface.
706 :param iface_key: Interface key from topology file.
707 :type nodes_info: dict
710 :returns: Return (node, interface_key) tuple or None if not found.
714 # get link name where the interface belongs to
715 for if_key, if_val in node['interfaces'].iteritems():
718 if if_key == iface_key:
719 link_name = if_val['link']
722 if link_name is None:
726 for node_data in nodes_info.values():
728 if node_data['host'] == node['host']:
731 in node_data['interfaces'].iteritems():
732 if 'link' not in if_val:
734 if if_val['link'] == link_name:
735 return node_data, if_key
739 def get_interface_pci_addr(node, iface_key):
740 """Get interface PCI address.
742 :param node: Node to get interface PCI address on.
743 :param iface_key: Interface key from topology file.
746 :returns: Return PCI address or None if not found.
749 return node['interfaces'][iface_key].get('pci_address')
754 def get_interface_driver(node, iface_key):
755 """Get interface driver.
757 :param node: Node to get interface driver on.
758 :param iface_key: Interface key from topology file.
761 :returns: Return interface driver or None if not found.
764 return node['interfaces'][iface_key].get('driver')
769 def get_interface_vlan(node, iface_key):
770 """Get interface vlan.
772 :param node: Node to get interface driver on.
773 :param iface_key: Interface key from topology file.
776 :returns: Return interface vlan or None if not found.
779 return node['interfaces'][iface_key].get('vlan')
784 def get_node_interfaces(node):
785 """Get all node interfaces.
787 :param node: Node to get list of interfaces from.
789 :returns: Return list of keys of all interfaces.
792 return node['interfaces'].keys()
795 def get_node_link_mac(node, link_name):
796 """Return interface mac address by link name.
798 :param node: Node to get interface sw_if_index on.
799 :param link_name: Link name.
802 :returns: MAC address string.
805 for port in node['interfaces'].values():
806 if port.get('link') == link_name:
807 return port.get('mac_address')
811 def _get_node_active_link_names(node, filter_list=None):
812 """Return list of link names that are other than mgmt links.
814 :param node: Node topology dictionary.
815 :param filter_list: Link filter criteria.
817 :type filter_list: list of strings
818 :returns: List of link names occupied by the node.
819 :rtype: None or list of string
821 interfaces = node['interfaces']
823 for interface in interfaces.values():
824 if 'link' in interface:
825 if (filter_list is not None) and ('model' in interface):
826 for filt in filter_list:
827 if filt == interface['model']:
828 link_names.append(interface['link'])
829 elif (filter_list is not None) and ('model' not in interface):
830 logger.trace('Cannot apply filter on interface: {}'
831 .format(str(interface)))
833 link_names.append(interface['link'])
838 @keyword('Get active links connecting "${node1}" and "${node2}"')
839 def get_active_connecting_links(self, node1, node2,
840 filter_list_node1=None,
841 filter_list_node2=None):
842 """Return list of link names that connect together node1 and node2.
844 :param node1: Node topology dictionary.
845 :param node2: Node topology dictionary.
846 :param filter_list_node1: Link filter criteria for node1.
847 :param filter_list_node2: Link filter criteria for node2.
850 :type filter_list_node1: list of strings
851 :type filter_list_node2: list of strings
852 :returns: List of strings that represent connecting link names.
856 logger.trace("node1: {}".format(str(node1)))
857 logger.trace("node2: {}".format(str(node2)))
858 node1_links = self._get_node_active_link_names(
860 filter_list=filter_list_node1)
861 node2_links = self._get_node_active_link_names(
863 filter_list=filter_list_node2)
865 connecting_links = None
866 if node1_links is None:
867 logger.error("Unable to find active links for node1")
868 elif node2_links is None:
869 logger.error("Unable to find active links for node2")
871 connecting_links = list(set(node1_links).intersection(node2_links))
873 return connecting_links
875 @keyword('Get first active connecting link between node "${node1}" and '
877 def get_first_active_connecting_link(self, node1, node2):
880 :param node1: Connected node.
881 :param node2: Connected node.
884 :returns: Name of a link connecting the two nodes together.
886 :raises RuntimeError: If no links are found.
888 connecting_links = self.get_active_connecting_links(node1, node2)
889 if not connecting_links:
890 raise RuntimeError("No links connecting the nodes were found")
891 return connecting_links[0]
893 @keyword('Get egress interfaces name on "${node1}" for link with '
895 def get_egress_interfaces_name_for_nodes(self, node1, node2):
896 """Get egress interfaces on node1 for link with node2.
898 :param node1: First node, node to get egress interface on.
899 :param node2: Second node.
902 :returns: Egress interfaces.
906 links = self.get_active_connecting_links(node1, node2)
908 raise RuntimeError('No link between nodes')
909 for interface in node1['interfaces'].values():
910 link = interface.get('link')
915 name = interface.get('name')
918 interfaces.append(name)
921 @keyword('Get first egress interface name on "${node1}" for link with '
923 def get_first_egress_interface_for_nodes(self, node1, node2):
924 """Get first egress interface on node1 for link with node2.
926 :param node1: First node, node to get egress interface name on.
927 :param node2: Second node.
930 :returns: Egress interface name.
933 interfaces = self.get_egress_interfaces_name_for_nodes(node1, node2)
935 raise RuntimeError('No egress interface for nodes')
938 @keyword('Get link data useful in circular topology test from tg "${tgen}"'
939 ' dut1 "${dut1}" dut2 "${dut2}"')
940 def get_links_dict_from_nodes(self, tgen, dut1, dut2):
941 """Return link combinations used in tests in circular topology.
943 For the time being it returns links from the Node path:
945 The naming convention until changed to something more general is
947 DUT1_DUT2_LINK: link name between DUT! and DUT2
948 DUT1_TG_LINK: link name between DUT1 and TG
949 DUT2_TG_LINK: link name between DUT2 and TG
950 TG_TRAFFIC_LINKS: list of link names that generated traffic is sent
952 DUT1_BD_LINKS: list of link names that will be connected by the bridge
954 DUT2_BD_LINKS: list of link names that will be connected by the bridge
957 :param tgen: Traffic generator node data.
958 :param dut1: DUT1 node data.
959 :param dut2: DUT2 node data.
963 :returns: Dictionary of possible link combinations.
966 # TODO: replace with generic function.
967 dut1_dut2_link = self.get_first_active_connecting_link(dut1, dut2)
968 dut1_tg_link = self.get_first_active_connecting_link(dut1, tgen)
969 dut2_tg_link = self.get_first_active_connecting_link(dut2, tgen)
970 tg_traffic_links = [dut1_tg_link, dut2_tg_link]
971 dut1_bd_links = [dut1_dut2_link, dut1_tg_link]
972 dut2_bd_links = [dut1_dut2_link, dut2_tg_link]
973 topology_links = {'DUT1_DUT2_LINK': dut1_dut2_link,
974 'DUT1_TG_LINK': dut1_tg_link,
975 'DUT2_TG_LINK': dut2_tg_link,
976 'TG_TRAFFIC_LINKS': tg_traffic_links,
977 'DUT1_BD_LINKS': dut1_bd_links,
978 'DUT2_BD_LINKS': dut2_bd_links}
979 return topology_links
982 def is_tg_node(node):
983 """Find out whether the node is TG.
985 :param node: Node to examine.
987 :returns: True if node is type of TG, otherwise False.
990 return node['type'] == NodeType.TG
993 def get_node_hostname(node):
994 """Return host (hostname/ip address) of the node.
996 :param node: Node created from topology.
998 :returns: Hostname or IP address.
1004 def get_node_arch(node):
1005 """Return arch of the node.
1006 Default to x86_64 if no arch present
1008 :param node: Node created from topology.
1010 :returns: Node architecture
1016 node['arch'] = 'x86_64'
1020 def get_cryptodev(node):
1021 """Return Crytodev configuration of the node.
1023 :param node: Node created from topology.
1025 :returns: Cryptodev configuration string.
1029 return node['cryptodev']
1034 def get_uio_driver(node):
1035 """Return uio-driver configuration of the node.
1037 :param node: Node created from topology.
1039 :returns: uio-driver configuration string.
1043 return node['uio_driver']
1048 def set_interface_numa_node(node, iface_key, numa_node_id):
1049 """Set interface numa_node location.
1051 :param node: Node to set numa_node on.
1052 :param iface_key: Interface key from topology file.
1054 :type iface_key: str
1055 :returns: Return iface_key or None if not found.
1058 node['interfaces'][iface_key]['numa_node'] = numa_node_id
1063 def add_new_socket(self, node, socket_type, socket_id, socket_path):
1064 """Add socket file of specific SocketType and ID to node.
1066 :param node: Node to add socket on.
1067 :param socket_type: Socket type.
1068 :param socket_id: Socket id.
1069 :param socket_path: Socket absolute path.
1071 :type socket_type: SocketType
1072 :type socket_id: str
1073 :type socket path: str
1075 path = ['sockets', socket_type, socket_id]
1076 self.add_node_item(node, socket_path, path)
1079 def get_node_sockets(node, socket_type=None):
1080 """Get node socket files.
1082 :param node: Node to get sockets from.
1083 :param socket_type: Socket type or None for all sockets.
1085 :type socket_type: SocketType
1086 :returns: Node sockets or None if not found.
1091 return node['sockets'][socket_type]
1092 return node['sockets']
1097 def clean_sockets_on_all_nodes(nodes):
1098 """Remove temporary socket files from topology file.
1100 :param nodes: SUT nodes.
1103 for node in nodes.values():
1104 if 'sockets' in node.keys():