Loading src/device/service/drivers/openconfig/templates/Interfaces.py +29 −21 Original line number Diff line number Diff line Loading @@ -20,14 +20,22 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: 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_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) for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES): LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface)))) subinterface = {} add_value_from_tag(subinterface, 'name', interface_name) 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) Loading @@ -35,25 +43,25 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: 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) #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']) Loading src/device/service/drivers/openconfig/templates/NetworkInstances.py +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: ni_route_dist = xml_network_instance.find('ocni:config/ocni:route-distinguisher', namespaces=NAMESPACES) add_value_from_tag(network_instance, 'route_distinguisher', ni_route_dist) ni_address_families = [] add_value_from_collection(network_instance, 'address_families', ni_address_families) #ni_address_families = [] #add_value_from_collection(network_instance, 'address_families', ni_address_families) if len(network_instance) == 0: continue response.append(('network_instance[{:s}]'.format(network_instance['name']), network_instance)) Loading src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -4,8 +4,10 @@ {% if operation is not defined or operation != 'delete' %} <config> <name>{{name}}</name> {% if 1==0 %} <description>{{description}}</description> <mtu>{{mtu}}</mtu> {% endif %} </config> {% endif %} <subinterfaces> Loading @@ -16,6 +18,11 @@ <index>{{index}}</index> </config> {% endif %} <vlan xmlns="http://openconfig.net/yang/vlan"> <config> <vlan-id>{{index}}</vlan-id> </config> </vlan> </subinterface> </subinterfaces> </interface> Loading src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml +12 −0 Original line number Diff line number Diff line Loading @@ -5,12 +5,24 @@ <config> <name>{{name}}</name> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type> {% if 1==0 %} {% for address_family in address_families %} <enabled-address-families xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:{{address_family}}</enabled-address-families> {% endfor %} {% else %} <description>PhiTst_1</description> {% endif %} <router-id>{{router_id}}</router-id> <route-distinguisher>{{route_distinguisher}}</route-distinguisher> <enabled>true</enabled> </config> <encapsulation> <config> <encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type> </config> </encapsulation> {% endif %} </network-instance> </network-instances> src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -7,7 +7,12 @@ {% if operation is not defined or operation != 'delete' %} <config> <id>{{id}}</id> {% if 1==0 %} <interface>{{id}}</interface> {% else %} <interface>13/1/2</interface> <subinterface>1</subinterface> {% endif %} </config> {% endif %} </interface> Loading Loading
src/device/service/drivers/openconfig/templates/Interfaces.py +29 −21 Original line number Diff line number Diff line Loading @@ -20,14 +20,22 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: 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_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) for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES): LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface)))) subinterface = {} add_value_from_tag(subinterface, 'name', interface_name) 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) Loading @@ -35,25 +43,25 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: 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) #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']) Loading
src/device/service/drivers/openconfig/templates/NetworkInstances.py +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: ni_route_dist = xml_network_instance.find('ocni:config/ocni:route-distinguisher', namespaces=NAMESPACES) add_value_from_tag(network_instance, 'route_distinguisher', ni_route_dist) ni_address_families = [] add_value_from_collection(network_instance, 'address_families', ni_address_families) #ni_address_families = [] #add_value_from_collection(network_instance, 'address_families', ni_address_families) if len(network_instance) == 0: continue response.append(('network_instance[{:s}]'.format(network_instance['name']), network_instance)) Loading
src/device/service/drivers/openconfig/templates/interface/subinterface/edit_config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -4,8 +4,10 @@ {% if operation is not defined or operation != 'delete' %} <config> <name>{{name}}</name> {% if 1==0 %} <description>{{description}}</description> <mtu>{{mtu}}</mtu> {% endif %} </config> {% endif %} <subinterfaces> Loading @@ -16,6 +18,11 @@ <index>{{index}}</index> </config> {% endif %} <vlan xmlns="http://openconfig.net/yang/vlan"> <config> <vlan-id>{{index}}</vlan-id> </config> </vlan> </subinterface> </subinterfaces> </interface> Loading
src/device/service/drivers/openconfig/templates/network_instance/edit_config.xml +12 −0 Original line number Diff line number Diff line Loading @@ -5,12 +5,24 @@ <config> <name>{{name}}</name> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type> {% if 1==0 %} {% for address_family in address_families %} <enabled-address-families xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:{{address_family}}</enabled-address-families> {% endfor %} {% else %} <description>PhiTst_1</description> {% endif %} <router-id>{{router_id}}</router-id> <route-distinguisher>{{route_distinguisher}}</route-distinguisher> <enabled>true</enabled> </config> <encapsulation> <config> <encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type> </config> </encapsulation> {% endif %} </network-instance> </network-instances>
src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -7,7 +7,12 @@ {% if operation is not defined or operation != 'delete' %} <config> <id>{{id}}</id> {% if 1==0 %} <interface>{{id}}</interface> {% else %} <interface>13/1/2</interface> <subinterface>1</subinterface> {% endif %} </config> {% endif %} </interface> Loading