Commit 8ad90509 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Code and MR cleanup

parent 01917779
Loading
Loading
Loading
Loading

file.txt

deleted100644 → 0
+0 −392

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −9
Changes for src/device/service/drivers/openconfig/templates/Interfaces.py: 0 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -43,15 +43,6 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
        interface_description = xml_interface.find('oci:config/oci:description', namespaces=NAMESPACES)
        add_value_from_tag(interface, 'description', interface_description)

        interface_mtu = xml_interface.find('oci:config/oci:mtu', namespaces=NAMESPACES)
        add_value_from_tag(interface, 'mtu',interface_mtu)
        

        interface_description = xml_interface.find('oci:config/oci:description', namespaces=NAMESPACES)
        add_value_from_tag(interface, 'description', interface_description)

        LOGGER.info('AAAAAAAAAAAAAAAAAAAAA: {:s}'.format(str(interface)))

        for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES):
            #LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface))))

+0 −74
Changes for src/device/service/drivers/openconfig/templates/Interfaces.py.save: 0 added lines, 74 removed lines.
Original line number Diff line number Diff line
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

LOGGER = logging.getLogger(__name__)

XPATH_INTERFACES    = "//oci:interfaces/oci:interface"
XPATH_SUBINTERFACES = ".//oci:subinterfaces/oci:subinterface"
XPATH_IPV4ADDRESSES = ".//ociip:ipv4/ociip:addresses/ociip:address"

def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
    response = []
    for xml_interface in xml_data.xpath(XPATH_INTERFACES, namespaces=NAMESPACES):
        LOGGER.info('xml_interface = {:s}'.format(str(ET.tostring(xml_interface))))

        interface = {}

        interface_name = xml_interface.find('oci:name', namespaces=NAMESPACES)
        if interface_name is None or interface_name.text is None: continue
        add_value_from_tag(interface, 'name', interface_name)

#        interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
#        add_value_from_tag(interface, 'type', interface_type)

        interface_mtu = xml_interface.find('oci:config/oci:mtu', namespaces=NAMESPACES)
        add_value_from_tag(interface, 'mtu',interface_mtu)
        

        interface_description = xml_interface.find('oci:config/oci:description', namespaces=NAMESPACES)
        add_value_from_tag(interface, 'description', interface_description)

        LOGGER.info('AAAAAAAAAAAAAAAAAAAAA: {:s}'.format(str(interface)))

        for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES):
            LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface))))

            subinterface = {}

            subinterface_index = xml_subinterface.find('oci:index', namespaces=NAMESPACES)
            if subinterface_index is None or subinterface_index.text is None: continue
            add_value_from_tag(subinterface, 'index', subinterface_index)

            vlan_id = xml_subinterface.find('ocv:vlan/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
            add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)

            ipv4_addresses = []
            for xml_ipv4_address in xml_subinterface.xpath(XPATH_IPV4ADDRESSES, namespaces=NAMESPACES):
                LOGGER.info('xml_ipv4_address = {:s}'.format(str(ET.tostring(xml_ipv4_address))))

                ipv4_address = {}

                origin = xml_ipv4_address.find('ociip:state/ociip:origin', namespaces=NAMESPACES)
                add_value_from_tag(ipv4_address, 'origin', origin)

                address = xml_ipv4_address.find('ociip:state/ociip:ip', namespaces=NAMESPACES)
                add_value_from_tag(ipv4_address, 'ip', address)

                prefix = xml_ipv4_address.find('ociip:state/ociip:prefix-length', namespaces=NAMESPACES)
                add_value_from_tag(ipv4_address, 'prefix_length', prefix)

                if len(ipv4_address) == 0: continue
                ipv4_addresses.append(ipv4_address)

            add_value_from_collection(subinterface, 'ipv4_addresses', ipv4_addresses)

            if len(subinterface) == 0: continue
            resource_key = 'interface[{:s}]/subinterface[{:s}]'.format(interface['name'], subinterface['index'])
            response.append((resource_key, subinterface))

        if len(interface) == 0: continue
        response.append(('interface[{:s}]'.format(interface['name']), interface))

    return response
+1 −1
Changes for src/device/service/drivers/openconfig/templates/NetworkInstances.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ XPATH_NETWORK_INSTANCES = "//ocni:network-instances/ocni:network-instance"
def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
    response = []
    for xml_network_instance in xml_data.xpath(XPATH_NETWORK_INSTANCES, namespaces=NAMESPACES):
        LOGGER.info('AQUIIIIIIIIII = {:s}'.format(str(ET.tostring(xml_network_instance))))
        LOGGER.info('xml_network_instance = {:s}'.format(str(ET.tostring(xml_network_instance))))

        network_instance = {}

+0 −1
Changes for src/device/tests/test_unitary.py: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ try:
        DEVICE_OC_UUID)
    ENABLE_OPENCONFIG = True
except ImportError:
    print("Hello there")
    ENABLE_OPENCONFIG = False

try: