File tree Expand file tree Collapse file tree 3 files changed +22
-8
lines changed
Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 22{{ name or i.ifname }}
33{% - endmacro %}
44
5- {% macro declare_router (i ,sub_path ="" ,intf_cfg =False ) -%}
5+ {% macro declare_router (i ,sub_path ="" ,intf_cfg =False , vrf_config = True ) -%}
66{#
77 This macro selects the SR/OS service in which the current object
88 is configured. The global routing instance is "router Base" unless
3232 else "service/vprn[service-name=" +service_name +"]" %}
3333
3434{# Minimal service config must exist #}
35- {% if not in_base %}
35+ {% if not in_base and vrf_config %}
3636- path: configure/{{ base_path }}
3737 val:
3838 customer: "1"
4444- path: configure/{{ base_path }}{{ sub_path }}
4545{% - endmacro %}
4646
47+ {#
48+ This macro is just a convenient wrapper around the more generic declare_router
49+ macro. That one expects an interface data structure and extracts VRF from it,
50+ this one takes VRF as the parameter (it can also be missing) and fakes the minimal
51+ data structure that makes declare_router happy
52+ #}
53+ {% macro configure_router (vrf ="" ,sub_path ="" ) -%}
54+ {% if vrf %}
55+ {{ declare_router({ 'vrf': vrf },sub_path=sub_path) }}
56+ {% else %}
57+ {{ declare_router({},sub_path=sub_path) }}
58+ {% endif %}
59+ {% - endmacro %}
60+
4761{% macro declare_interface (i ,name =None ) %}
4862{% set ifname = if_name (i ,name or i .ifname ) %}
4963{{ declare_router(i,sub_path="/interface[interface-name=" + ifname + "] ",intf_cfg=True) }}
Original file line number Diff line number Diff line change 1- {% from "templates/initial/sros.j2" import if_name , declare_router with context %}
1+ {% from "templates/initial/sros.j2" import if_name , configure_router with context %}
22{% from 'templates/routing/_redistribute.sros.j2' import import_protocols with context %}
33
44{% macro isis_export_policy (isis ,vrf ) %}
1010{{ import_protocols(isis.import) | indent(4,first=True) }}
1111{% endmacro %}
1212
13- {% macro isis_router (vrf_data , isis ,intf_list ) %}
14- {% set vname = vrf_data . vrf |default ( 'default' ) %}
13+ {% macro isis_router (isis ,intf_list =[], vrf_name = "" ) %}
14+ {% set vname = vrf_name or 'default' %}
1515{% if isis .import is defined %}
1616{{ isis_export_policy(isis,vname) }}
1717{% endif %}
1818{% set kw_level = {'level-1' : '1' , 'level-2' : '2' , 'level-1-2' : '1/2' } %}
19- {{ declare_router(vrf_data ) }}
19+ {{ configure_router(vrf_name ) }}
2020 val:
2121 isis:
2222 - isis-instance: 0
7171
7272updates:
7373{% if isis is defined %}
74- {{ isis_router({}, isis,netlab_interfaces) }}
74+ {{ isis_router(isis,netlab_interfaces) }}
7575{% endif %}
Original file line number Diff line number Diff line change @@ -27,6 +27,6 @@ updates:
2727{% endfor %}
2828{% endif %}
2929{% if 'isis' in vdata and 'af' in vdata %}
30- {{ isis_router({ 'vrf': vname }, vdata.isis,vdata.isis.interfaces) }}
30+ {{ isis_router(vdata.isis,vdata.isis.interfaces,vname ) }}
3131{% endif %}
3232{% endfor %}
You can’t perform that action at this time.
0 commit comments