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

Device component - NETCONF OpenConfig Driver:

- Enhance management of MTU, VLAN Id, and address family fields
- Include tests (under development)
parent fdc6ac60
Loading
Loading
Loading
Loading
+31 −19
Original line number Diff line number Diff line
@@ -68,12 +68,14 @@ def create_NI(parameters,vendor,DEL):
                            with tag('router-id'):text(parameters['router_id'])
                        if vendor is None or vendor == 'ADVA':
                            with tag('type', 'xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types"'):text('oc-ni-types:',parameters['type'])
                            with tag('enable'):text('true')
                            with tag('enabled-address-families', 'xmlns:oc-types="http://openconfig.net/yang/openconfig-types"'):text('oc-types:IPV4')
                            with tag('route-distinguisher'):text(parameters['route_distinguisher'])
                    if vendor is None or vendor == 'ADVA':
                        with tag('encapsulation'):
                            with tag('config'):
                                with tag('encapsulation-type', 'xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types"')  :text('oc-ni-types:MPLS')
                                with tag('label-allocation-mode','xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types"'):text('oc-ni-types:INSTANCE_LABEL')
                    #if vendor is None or vendor == 'ADVA':
                    #    with tag('encapsulation'):
                    #        with tag('config'):
                    #            with tag('encapsulation-type', 'xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types"')  :text('oc-ni-types:MPLS')
                    #            with tag('label-allocation-mode','xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types"'):text('oc-ni-types:INSTANCE_LABEL')

    result = indent(
        doc.getvalue(),
@@ -147,6 +149,8 @@ def add_protocol_NI(parameters,vendor, DEL):
                                                with tag('neighbor-address'): text(neighbor['ip_address'])
                                                with tag('afi-safis'):
                                                    with tag('afi-safi', 'xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types"'):
                                                        with tag('afi-safi-name'): text('oc-bgp-types:IPV4_UNICAST')
                                                        with tag('config'):
                                                            with tag('afi-safi-name'): text('oc-bgp-types:IPV4_UNICAST')
                                                            with tag('enabled'): text('true')
                                                with tag('config'):
@@ -294,12 +298,20 @@ def associate_RP_to_NI(parameters):
        with tag('network-instance'):
            with tag('name'): text(parameters['name'])
            with tag('inter-instance-policies'):
                if 'import_policy' in parameters or 'export_policy' in parameters:
                    with tag('apply-policy'):
                        with tag('config'):
                            if 'import_policy' in parameters:
                                with tag('import-policy'): text(parameters['import_policy'])
                      elif 'export_policy' in parameters:
                            if 'export_policy' in parameters:
                                with tag('export-policy'): text(parameters['export_policy'])
                if 'import_route_target' in parameters or 'export_route_target' in parameters:
                    with tag('import-export-policy'):
                        with tag('config'):
                            if 'import_route_target' in parameters:
                                with tag('import-route-target'): text(parameters['import_route_target'])
                            if 'export_route_target' in parameters:
                                with tag('export-route-target'): text(parameters['export_route_target'])
    result = indent(
        doc.getvalue(),
        indentation = ' '*2,
@@ -343,7 +355,7 @@ def create_table_conns(parameters,DEL):
                      with tag('dst-protocol', 'xmlns:oc-pol-types="http://openconfig.net/yang/policy-types"'):   text('oc-pol-types:',parameters['dst_protocol'])
                      with tag('address-family', 'xmlns:oc-types="http://openconfig.net/yang/openconfig-types"'):text('oc-types:',parameters['address_family'])     
            else:
                with tag('table-connections'):
                with tag('table-connections', 'xmlns:oc-types="http://openconfig.net/yang/openconfig-types"'):
                    with tag('table-connection'):
                      with tag('src-protocol','xmlns:oc-pol-types="http://openconfig.net/yang/policy-types"'):   text('oc-pol-types:',parameters['src_protocol'])
                      with tag('dst-protocol','xmlns:oc-pol-types="http://openconfig.net/yang/policy-types"'):   text('oc-pol-types:',parameters['dst_protocol'])
+10 −2
Original line number Diff line number Diff line
@@ -6,8 +6,16 @@
            <name>{{name}}</name>
            <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type>
            <description></description>
            <mtu>{{mtu}}</mtu>
            {% if mtu is defined %}<mtu>{{mtu}}</mtu>{% endif %}
        </config>
        {% if auto_negotiate is defined or port_speed is defined %}
        <ethernet xmlns="http://openconfig.net/yang/interfaces/ethernet">
            <config>
                {% if auto_negotiate is defined %}<auto-negotiate>{{auto_negotiate}}</auto-negotiate>{% endif %}
                {% if port_speed is defined %}<port-speed>{{port_speed}}</port-speed>{% endif %}
            </config>
        </ethernet>
        {% endif %}
        {% endif %}
    </interface>
</interfaces>
+22 −3
Original line number Diff line number Diff line
@@ -8,6 +8,14 @@
            {% if mtu is defined %}<mtu>{{mtu}}</mtu>{% endif %}
            <enabled>true</enabled>
        </config>
        {% if auto_negotiate is defined or port_speed is defined %}
        <ethernet xmlns="http://openconfig.net/yang/interfaces/ethernet">
            <config>
                {% if auto_negotiate is defined %}<auto-negotiate>{{auto_negotiate}}</auto-negotiate>{% endif %}
                {% if port_speed is defined %}<port-speed>{{port_speed}}</port-speed>{% endif %}
            </config>
        </ethernet>
        {% endif %}
        <subinterfaces>
            <subinterface>
                <index>{{index}}</index>
@@ -18,14 +26,25 @@
                    <untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed>
                    {% endif%}
                </config>
                {% if vlan_id is defined %}
                {% if vlan_id is defined or vlan_ids is defined %}
                <vlan xmlns="http://openconfig.net/yang/vlan">
                    <match>
                        {% if vlan_id is defined %}
                        <single-tagged>
                            <config>
                                <vlan-id>{{vlan_id}}</vlan-id>
                            </config>
                        </single-tagged>
                        {% endif %}
                        {% if vlan_ids is defined %}
                        <single-tagged-list>
                            <config>
                            {% for vlan_id in vlan_ids %}
                                <vlan-ids>{{vlan_id}}</vlan-ids>
                            {% endfor %}
                            </config>
                        </single-tagged-list>
                        {% endif %}
                    </match>
                </vlan>
                {% endif %}
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
            {% if description is defined %}<description>{{description}}</description>{% endif %}
            <enabled>true</enabled>
            {% if type=='L3VRF' %}
            <enabled-address-families xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</enabled-address-families>
            {% if router_id is defined %}<router-id>{{router_id}}</router-id>{% endif %}
            <route-distinguisher>{{route_distinguisher}}</route-distinguisher>
            {% endif %}
+10 −0
Original line number Diff line number Diff line
@@ -3,12 +3,22 @@
    <network-instance>
        <name>{{name}}</name>
        <inter-instance-policies>
            {% if import_policy is defined or export_policy is defined %}
            <apply-policy>
                <config>
                    {% if import_policy is defined %}<import-policy>{{import_policy}}</import-policy>{% endif%}
                    {% if export_policy is defined %}<export-policy>{{export_policy}}</export-policy>{% endif%}
                </config>
            </apply-policy>
            {% endif%}
            {% if import_route_target is defined or export_route_target is defined %}
            <import-export-policy>
                <config>
                    {% if import_route_target is defined %}<import-route-target>{{import_route_target}}</import-route-target>{% endif%}
                    {% if export_route_target is defined %}<export-route-target>{{export_route_target}}</export-route-target>{% endif%}
                </config>
            </import-export-policy>
            {% endif%}
        </inter-instance-policies>
    </network-instance>
</network-instances>
Loading