X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Ftopology.py;h=791b07053c2a7ae3180e4e970acaad5bc6cf593f;hp=3c903e5c94c1ac809f1d0307e3b3ec5fb54ca88f;hb=9a261ea61549fc6a5c23369d2e236b002dc35038;hpb=4dadc7a005ca99aa5a14ac650e9aa187cea10619 diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py index 3c903e5c94..791b07053c 100644 --- a/resources/libraries/python/topology.py +++ b/resources/libraries/python/topology.py @@ -18,7 +18,7 @@ from collections import Counter from yaml import load from robot.api import logger -from robot.libraries.BuiltIn import BuiltIn +from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError from robot.api.deco import keyword __all__ = ["DICT__nodes", 'Topology'] @@ -27,11 +27,11 @@ __all__ = ["DICT__nodes", 'Topology'] def load_topo_from_yaml(): """Load topology from file defined in "${TOPOLOGY_PATH}" variable. - :return: Nodes from loaded topology. + :returns: Nodes from loaded topology. """ try: topo_path = BuiltIn().get_variable_value("${TOPOLOGY_PATH}") - except: + except RobotNotRunningError: return '' with open(topo_path) as work_file: @@ -39,6 +39,7 @@ def load_topo_from_yaml(): # pylint: disable=invalid-name + class NodeType(object): """Defines node types used in topology dictionaries.""" # Device Under Test (this node has VPP running on it) @@ -125,6 +126,19 @@ class Topology(object): """ node['interfaces'][iface_key]['vpp_sw_index'] = int(sw_if_index) + @staticmethod + def update_interface_name(node, iface_key, name): + """Update name on the interface from the node. + + :param node: Node to update name on. + :param iface_key: Topology key of the interface. + :param name: Interface name to store. + :type node: dict + :type iface_key: str + :type name: str + """ + node['interfaces'][iface_key]['name'] = str(name) + @staticmethod def update_interface_mac_address(node, iface_key, mac_address): """Update mac_address on the interface from the node. @@ -299,7 +313,7 @@ class Topology(object): try: if isinstance(iface_key, basestring): return node['interfaces'][iface_key].get('vpp_sw_index') - #FIXME: use only iface_key, do not use integer + # TODO: use only iface_key, do not use integer else: return int(iface_key) except (KeyError, ValueError): @@ -791,6 +805,34 @@ class Topology(object): """ return node['host'] + @staticmethod + def get_cryptodev(node): + """Return Crytodev configuration of the node. + + :param node: Node created from topology. + :type node: dict + :return: Cryptodev configuration string. + :rtype: str + """ + try: + return node['cryptodev'] + except KeyError: + return None + + @staticmethod + def get_uio_driver(node): + """Return uio-driver configuration of the node. + + :param node: Node created from topology. + :type node: dict + :return: uio-driver configuration string. + :rtype: str + """ + try: + return node['uio_driver'] + except KeyError: + return None + @staticmethod def set_interface_numa_node(node, iface_key, numa_node_id): """Set interface numa_node location.