Loading src/device/service/drivers/openconfig/templates/EndPoints.py +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: component_type = xml_component.find('ocp:state/ocp:type', namespaces=NAMESPACES) if component_type is None or component_type.text is None: continue component_type = component_type.text if component_type not in {'PORT', 'oc-platform-types:PORT'}: continue if component_type not in {'PORT', 'oc-platform-types:PORT', 'idx:PORT'}: continue LOGGER.info('PORT xml_component = {:s}'.format(str(ET.tostring(xml_component)))) Loading src/device/service/drivers/openconfig/templates/Interfaces.py +14 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import logging, lxml.etree as ET from typing import Any, Dict, List, Tuple from .Namespace import NAMESPACES from .Tools import add_value_from_collection, add_value_from_tag from .Tools import add_value_from_tag LOGGER = logging.getLogger(__name__) Loading @@ -37,8 +37,18 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: #interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) #add_value_from_tag(interface, 'type', interface_type) if xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) is not None: interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) interface_type.text = interface_type.text.replace('ianaift:','') elif xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES) is not None: interface_type = xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES) else: interface_type = '' # Get the type of interface according to the vendor's type if 'ianaift:' in interface_type.text: interface_type.text = interface_type.text.replace('ianaift:', '') #ADVA elif 'idx'in interface_type.text: interface_type.text = interface_type.text.replace('idx:', '') #CISCO add_value_from_tag(interface, 'type', interface_type) interface_mtu = xml_interface.find('oci:config/oci:mtu', namespaces=NAMESPACES) Loading src/device/service/drivers/openconfig/templates/NetworkInstances.py +15 −1 Original line number Diff line number Diff line Loading @@ -41,9 +41,23 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: if ni_name is None or ni_name.text is None: continue add_value_from_tag(network_instance, 'name', ni_name) ''' ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) ni_type.text = ni_type.text.replace('oc-ni-types:','') add_value_from_tag(network_instance, 'type', ni_type) ''' if xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) is not None: ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) elif xml_network_instance.find('oci:state/oci:type', namespaces=NAMESPACES) is not None: ni_type = xml_network_instance.find('oci:state/oci:type', namespaces=NAMESPACES) else: continue if 'oc-ni-types:' in ni_type.text: ni_type.text = ni_type.text.replace('oc-ni-types:', '') #ADVA elif 'idx'in ni_type.text: ni_type.text = ni_type.text.replace('idx:', '') #CISCO add_value_from_tag(network_instance, 'type', ni_type) ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES) add_value_from_tag(network_instance, 'router_id', ni_router_id) Loading src/device/service/drivers/openconfig/templates/RoutingPolicy.py +6 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: for xml_statement in xml_policy_definition.xpath(XPATH_PD_STATEMENTS, namespaces=NAMESPACES): statement_name = xml_statement.find('ocrp:name', namespaces=NAMESPACES) if len(statement_name) != 0: #FIX: In case there is a route policy defined without a statement name add_value_from_tag(policy_definition, 'statement_name', statement_name) for xml_condition in xml_statement.xpath(XPATH_PD_ST_CONDITIONS, namespaces=NAMESPACES): Loading @@ -58,6 +59,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: policy_result = xml_action.find('ocbp:config/ocbp:policy-result', namespaces=NAMESPACES) add_value_from_tag(policy_definition, 'policy_result', policy_result) if len(statement_name) != 0: #FIX: In case there is a route policy defined without a statement name resource_key = '/routing_policy/policy_definition[{:s}]/statement[{:s}]'.format( policy_definition['policy_name'], policy_definition['statement_name']) response.append((resource_key, copy.deepcopy(policy_definition))) Loading Loading
src/device/service/drivers/openconfig/templates/EndPoints.py +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: component_type = xml_component.find('ocp:state/ocp:type', namespaces=NAMESPACES) if component_type is None or component_type.text is None: continue component_type = component_type.text if component_type not in {'PORT', 'oc-platform-types:PORT'}: continue if component_type not in {'PORT', 'oc-platform-types:PORT', 'idx:PORT'}: continue LOGGER.info('PORT xml_component = {:s}'.format(str(ET.tostring(xml_component)))) Loading
src/device/service/drivers/openconfig/templates/Interfaces.py +14 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import logging, lxml.etree as ET from typing import Any, Dict, List, Tuple from .Namespace import NAMESPACES from .Tools import add_value_from_collection, add_value_from_tag from .Tools import add_value_from_tag LOGGER = logging.getLogger(__name__) Loading @@ -37,8 +37,18 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: #interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) #add_value_from_tag(interface, 'type', interface_type) if xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) is not None: interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) interface_type.text = interface_type.text.replace('ianaift:','') elif xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES) is not None: interface_type = xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES) else: interface_type = '' # Get the type of interface according to the vendor's type if 'ianaift:' in interface_type.text: interface_type.text = interface_type.text.replace('ianaift:', '') #ADVA elif 'idx'in interface_type.text: interface_type.text = interface_type.text.replace('idx:', '') #CISCO add_value_from_tag(interface, 'type', interface_type) interface_mtu = xml_interface.find('oci:config/oci:mtu', namespaces=NAMESPACES) Loading
src/device/service/drivers/openconfig/templates/NetworkInstances.py +15 −1 Original line number Diff line number Diff line Loading @@ -41,9 +41,23 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: if ni_name is None or ni_name.text is None: continue add_value_from_tag(network_instance, 'name', ni_name) ''' ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) ni_type.text = ni_type.text.replace('oc-ni-types:','') add_value_from_tag(network_instance, 'type', ni_type) ''' if xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) is not None: ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES) elif xml_network_instance.find('oci:state/oci:type', namespaces=NAMESPACES) is not None: ni_type = xml_network_instance.find('oci:state/oci:type', namespaces=NAMESPACES) else: continue if 'oc-ni-types:' in ni_type.text: ni_type.text = ni_type.text.replace('oc-ni-types:', '') #ADVA elif 'idx'in ni_type.text: ni_type.text = ni_type.text.replace('idx:', '') #CISCO add_value_from_tag(network_instance, 'type', ni_type) ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES) add_value_from_tag(network_instance, 'router_id', ni_router_id) Loading
src/device/service/drivers/openconfig/templates/RoutingPolicy.py +6 −4 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: for xml_statement in xml_policy_definition.xpath(XPATH_PD_STATEMENTS, namespaces=NAMESPACES): statement_name = xml_statement.find('ocrp:name', namespaces=NAMESPACES) if len(statement_name) != 0: #FIX: In case there is a route policy defined without a statement name add_value_from_tag(policy_definition, 'statement_name', statement_name) for xml_condition in xml_statement.xpath(XPATH_PD_ST_CONDITIONS, namespaces=NAMESPACES): Loading @@ -58,6 +59,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: policy_result = xml_action.find('ocbp:config/ocbp:policy-result', namespaces=NAMESPACES) add_value_from_tag(policy_definition, 'policy_result', policy_result) if len(statement_name) != 0: #FIX: In case there is a route policy defined without a statement name resource_key = '/routing_policy/policy_definition[{:s}]/statement[{:s}]'.format( policy_definition['policy_name'], policy_definition['statement_name']) response.append((resource_key, copy.deepcopy(policy_definition))) Loading