Skip to content
Snippets Groups Projects
Commit c0b557cf authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/device-openconfig' into 'develop'

Merge feat/device-openconfig into develop

See merge request teraflow-h2020/controller!70
parents 04d5a299 a75da49d
No related branches found
No related tags found
1 merge request!54Release 2.0.0
...@@ -20,14 +20,22 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: ...@@ -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 if interface_name is None or interface_name.text is None: continue
add_value_from_tag(interface, 'name', interface_name) add_value_from_tag(interface, 'name', interface_name)
interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES) #interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
add_value_from_tag(interface, 'type', interface_type) #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): for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES):
LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface)))) LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface))))
subinterface = {} subinterface = {}
add_value_from_tag(subinterface, 'name', interface_name)
subinterface_index = xml_subinterface.find('oci:index', namespaces=NAMESPACES) subinterface_index = xml_subinterface.find('oci:index', namespaces=NAMESPACES)
if subinterface_index is None or subinterface_index.text is None: continue if subinterface_index is None or subinterface_index.text is None: continue
add_value_from_tag(subinterface, 'index', subinterface_index) add_value_from_tag(subinterface, 'index', subinterface_index)
...@@ -35,25 +43,25 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: ...@@ -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) 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) add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)
ipv4_addresses = [] #ipv4_addresses = []
for xml_ipv4_address in xml_subinterface.xpath(XPATH_IPV4ADDRESSES, namespaces=NAMESPACES): #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)))) # LOGGER.info('xml_ipv4_address = {:s}'.format(str(ET.tostring(xml_ipv4_address))))
#
ipv4_address = {} # ipv4_address = {}
#
origin = xml_ipv4_address.find('ociip:state/ociip:origin', namespaces=NAMESPACES) # origin = xml_ipv4_address.find('ociip:state/ociip:origin', namespaces=NAMESPACES)
add_value_from_tag(ipv4_address, 'origin', origin) # add_value_from_tag(ipv4_address, 'origin', origin)
#
address = xml_ipv4_address.find('ociip:state/ociip:ip', namespaces=NAMESPACES) # address = xml_ipv4_address.find('ociip:state/ociip:ip', namespaces=NAMESPACES)
add_value_from_tag(ipv4_address, 'ip', address) # add_value_from_tag(ipv4_address, 'ip', address)
#
prefix = xml_ipv4_address.find('ociip:state/ociip:prefix-length', namespaces=NAMESPACES) # prefix = xml_ipv4_address.find('ociip:state/ociip:prefix-length', namespaces=NAMESPACES)
add_value_from_tag(ipv4_address, 'prefix_length', prefix) # add_value_from_tag(ipv4_address, 'prefix_length', prefix)
#
if len(ipv4_address) == 0: continue # if len(ipv4_address) == 0: continue
ipv4_addresses.append(ipv4_address) # ipv4_addresses.append(ipv4_address)
#
add_value_from_collection(subinterface, 'ipv4_addresses', ipv4_addresses) #add_value_from_collection(subinterface, 'ipv4_addresses', ipv4_addresses)
if len(subinterface) == 0: continue if len(subinterface) == 0: continue
resource_key = 'interface[{:s}]/subinterface[{:s}]'.format(interface['name'], subinterface['index']) resource_key = 'interface[{:s}]/subinterface[{:s}]'.format(interface['name'], subinterface['index'])
......
...@@ -27,8 +27,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: ...@@ -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) 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) add_value_from_tag(network_instance, 'route_distinguisher', ni_route_dist)
ni_address_families = [] #ni_address_families = []
add_value_from_collection(network_instance, 'address_families', ni_address_families) #add_value_from_collection(network_instance, 'address_families', ni_address_families)
if len(network_instance) == 0: continue if len(network_instance) == 0: continue
response.append(('network_instance[{:s}]'.format(network_instance['name']), network_instance)) response.append(('network_instance[{:s}]'.format(network_instance['name']), network_instance))
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
{% if operation is not defined or operation != 'delete' %} {% if operation is not defined or operation != 'delete' %}
<config> <config>
<name>{{name}}</name> <name>{{name}}</name>
{% if 1==0 %}
<description>{{description}}</description> <description>{{description}}</description>
<mtu>{{mtu}}</mtu> <mtu>{{mtu}}</mtu>
{% endif %}
</config> </config>
{% endif %} {% endif %}
<subinterfaces> <subinterfaces>
...@@ -16,6 +18,11 @@ ...@@ -16,6 +18,11 @@
<index>{{index}}</index> <index>{{index}}</index>
</config> </config>
{% endif %} {% endif %}
<vlan xmlns="http://openconfig.net/yang/vlan">
<config>
<vlan-id>{{index}}</vlan-id>
</config>
</vlan>
</subinterface> </subinterface>
</subinterfaces> </subinterfaces>
</interface> </interface>
......
...@@ -5,12 +5,24 @@ ...@@ -5,12 +5,24 @@
<config> <config>
<name>{{name}}</name> <name>{{name}}</name>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type> <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 %} {% 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> <enabled-address-families xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:{{address_family}}</enabled-address-families>
{% endfor %} {% endfor %}
{% else %}
<description>PhiTst_1</description>
{% endif %}
<router-id>{{router_id}}</router-id> <router-id>{{router_id}}</router-id>
<route-distinguisher>{{route_distinguisher}}</route-distinguisher> <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> </config>
</encapsulation>
{% endif %} {% endif %}
</network-instance> </network-instance>
</network-instances> </network-instances>
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
{% if operation is not defined or operation != 'delete' %} {% if operation is not defined or operation != 'delete' %}
<config> <config>
<id>{{id}}</id> <id>{{id}}</id>
{% if 1==0 %}
<interface>{{id}}</interface> <interface>{{id}}</interface>
{% else %}
<interface>13/1/2</interface>
<subinterface>1</subinterface>
{% endif %}
</config> </config>
{% endif %} {% endif %}
</interface> </interface>
......
# Add here your files containing confidential testbed details such as IP addresses, ports, usernames, passwords, etc. # Add here your files containing confidential testbed details such as IP addresses, ports, usernames, passwords, etc.
Device_OpenConfig_Infinera.py Device_OpenConfig_Infinera.py
Device_OpenConfig_Infinera_TID.py
Device_Transport_Api_CTTC.py Device_Transport_Api_CTTC.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment