X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Ftopology.py;h=0214cc9c027d07d2e47c177770afc030ecdd5f5f;hb=176eda8bf7775a2c761a6544ab932c2bc59dfa57;hp=5884ddf743a99ed2646b95c771f096a97a44ef33;hpb=233683de57527f477bf7e8d042a5f3d1f08c7744;p=csit.git diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py index 5884ddf743..0214cc9c02 100644 --- a/resources/libraries/python/topology.py +++ b/resources/libraries/python/topology.py @@ -29,7 +29,10 @@ def load_topo_from_yaml(): :return: Nodes from loaded topology. """ - topo_path = BuiltIn().get_variable_value("${TOPOLOGY_PATH}") + try: + topo_path = BuiltIn().get_variable_value("${TOPOLOGY_PATH}") + except: + return '' with open(topo_path) as work_file: return load(work_file.read())['nodes'] @@ -122,6 +125,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.