From 78ebaf0fa77e9a4f6991a5aa9934efed7c89125a Mon Sep 17 00:00:00 2001 From: armingol Date: Mon, 18 Mar 2024 14:40:57 +0100 Subject: [PATCH] Add interface information to network instance --- .../openconfig/templates/NetworkInstances.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/device/service/drivers/openconfig/templates/NetworkInstances.py b/src/device/service/drivers/openconfig/templates/NetworkInstances.py index c00995b3a..9de16d0e9 100644 --- a/src/device/service/drivers/openconfig/templates/NetworkInstances.py +++ b/src/device/service/drivers/openconfig/templates/NetworkInstances.py @@ -23,6 +23,8 @@ XPATH_NETWORK_INSTANCES = "//ocni:network-instances/ocni:network-instance" XPATH_NI_PROTOCOLS = ".//ocni:protocols/ocni:protocol" XPATH_NI_TABLE_CONNECTS = ".//ocni:table-connections/ocni:table-connection" +XPATH_NI_INTERFACE = ".//ocni:interfaces/ocni:interface" + XPATH_NI_IIP_AP = ".//ocni:inter-instance-policies/ocni:apply-policy" XPATH_NI_IIP_AP_IMPORT = ".//ocni:config/ocni:import-policy" XPATH_NI_IIP_AP_EXPORT = ".//ocni:config/ocni:export-policy" @@ -136,6 +138,21 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: table_connection['address_family']) response.append((resource_key, table_connection)) + for xml_interface in xml_network_instance.xpath(XPATH_NI_INTERFACE, namespaces=NAMESPACES): + LOGGER.info('xml_interfaces = {:s}'.format(str(ET.tostring(xml_interface)))) + + interface = {} + name_iface = xml_interface.find('ocni:config/ocni:interface', namespaces=NAMESPACES) + if name_iface is None or name_iface.text is None: continue + add_value_from_tag(interface, 'name_iface', name_iface) + + name_subiface = xml_interface.find('ocni:config/ocni:subinterface', namespaces=NAMESPACES) + add_value_from_tag(interface, 'name_subiface', name_subiface) + + resource_key = '/network_instance[{:s}]/interface[{:s}]'.format( + network_instance['name'], interface['name_iface']) + response.append((resource_key, interface)) + for xml_iip_ap in xml_network_instance.xpath(XPATH_NI_IIP_AP, namespaces=NAMESPACES): #LOGGER.info('xml_iip_ap = {:s}'.format(str(ET.tostring(xml_iip_ap)))) -- GitLab