<network-instances xmlns="http://openconfig.net/yang/network-instance">
    <network-instance{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
        <name>{{name}}</name>
        {% if operation is not defined or operation != 'delete' %}
        <config>
            <name>{{name}}</name>
            <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type>
            {% if type=='L3VRF' %}
            {% if description is defined %}<description>{{description}}</description>{% endif %}
            {% if router_id is defined %}<router-id>{{router_id}}</router-id>{% endif %}
            <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>
                <label-allocation-mode xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:INSTANCE_LABEL</label-allocation-mode>
            </config>
        </encapsulation>
            {% endif %}
            {% if type=='L2VSI' %}
            {% if description is defined %}<description>{{description}}</description>{% endif %}
            <enabled>true</enabled>
            <mtu>1500</mtu>
        </config>
        <encapsulation>
            <config>
                <encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type>
            </config>
        </encapsulation>
        <fdb>
            <config>
                <mac-learning>true</mac-learning>
                <maximum-entries>1000</maximum-entries>
                <mac-aging-time>300</mac-aging-time>
            </config>
        </fdb>
            {% endif %}

        {% endif %}
    </network-instance>
</network-instances>
