diff --git a/geant/gap_ansible/roles/base_config/tasks/merge_variables.yaml b/geant/gap_ansible/roles/base_config/tasks/merge_variables.yaml index fd244bc36e7b5b5b376d8ff1148a2e603c5e7130..67f053571a1e027901e8892f9c38eefe96bd94c5 100644 --- a/geant/gap_ansible/roles/base_config/tasks/merge_variables.yaml +++ b/geant/gap_ansible/roles/base_config/tasks/merge_variables.yaml @@ -29,7 +29,7 @@ cpm_filters: "{{ lookup('community.general.merge_variables', 'cpmf__to_merge', pattern_type='suffix') }}" - name: Prepare PE-specific vars - when: verb == "deploy_pe_base_config" + when: router_role == "pe" block: - name: Merge Nokia PE CPM filters ansible.builtin.set_fact: @@ -39,7 +39,17 @@ ansible.builtin.set_fact: cpm_filters: "{{ [cpm_filters, pe_cpm] | community.general.lists_mergeby('family', list_merge='append') }}" + - name: Merge P and PE prefix-lists ansible.builtin.set_fact: - nokia_prefix_lists: "{{ [nokia_prefix_lists, nokia_pe_prefix_lists] | community.general.lists_mergeby('name', + nokia_prefix_lists: "{{ [nokia_prefix_lists, nokia_pe_prefix_lists, nokia_pe_ias_prefix_lists] | community.general.lists_mergeby('name', list_merge='append') }}" + + - name: Merge P and PE source-addresses + ansible.builtin.set_fact: + nokia_applications: "{{ [nokia_applications, nokia_pe_applications] | community.general.lists_mergeby('name', list_merge='append') }}" + + + - name: Select SDP params for l2ciruit-type + ansible.builtin.set_fact: + sdp_type: "{{ (sdp_types | selectattr('id', 'equalto', '1'))[0] }}" diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/base_config.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/base_config.j2 index 590a0eb80eef631773ee3757357f8a7a858391f4..a3fc0e26751b51c1a8a1464875375d97634df457 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/base_config.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/base_config.j2 @@ -6,11 +6,19 @@ {% include 'sfm.j2' %} {% include 'cards.j2' %} {% include 'connectors.j2' %} - {#{% include 'ntp.j2' %}#} - {#{% include 'ip_prefix_list.j2' %}#} - {#{% include 'filters/cpm_filters.j2' %}#} - {#{% include 'syslog/syslog.j2' %}#} - {#{% include 'system/security/security.j2' %}#} - {#{% include 'qos/qos.j2' %}#} + {% include 'ntp.j2' %} + {% include 'filters/cpm_filters.j2' %} + {% include 'syslog/syslog.j2' %} + {% include 'system/security/security.j2' %} + {% include 'qos/qos.j2' %} + {% if router_role == 'pe' %} + {% include 'cflowd.j2' %} + {% include 'filter_log.j2' %} + {% include 'policy_options/policy_options.j2' %} + {% include 'service_vprn.j2' %} + {% endif %} + {# This is because `ip_prefix_list` is related to what defined in VPRN apply_paths #} + {% include 'ip_prefix_list.j2' %} + </configure> </config> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/cflowd.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/cflowd.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ef8dcc9feaa4c0f5bb8e225f3e5e546dc432b375 --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/cflowd.j2 @@ -0,0 +1,29 @@ +<cflowd xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes" alu:operation="replace"> + <cache-size>{{ cflowd.basic.cache_size }}</cache-size> + <enhanced-distribution>{{ cflowd.basic.enhanced_distribution }}</enhanced-distribution> + <overflow>{{ cflowd.basic.overflow }}</overflow> + <template-retransmit>{{ cflowd.basic.template_retransmit }}</template-retransmit> + <active-flow-timeout>{{ cflowd.basic.active_flow_timeout }}</active-flow-timeout> + <inactive-flow-timeout>{{ cflowd.basic.inactive_flow_timeout }}</inactive-flow-timeout> + {% if cflowd.sample_profiles is defined %} + {% for profile in cflowd.sample_profiles %} + <sample-profile> + <profile-id>{{ profile.id }}</profile-id> + <sample-rate>{{ profile.sample_rate }}</sample-rate> + <metering-process>{{ profile.metering_process }}</metering-process> + </sample-profile> + {% endfor %} + {% endif %} + {% if cflowd.collectors is defined %} + {% for collector in cflowd.collectors %} + <collector> + <ip-address>{{ collector.ip }}</ip-address> + <port>{{ collector.port }}</port> + <description>{{ collector.description }}</description> + <template-set>{{ collector.template_set }}</template-set> + <version>{{ collector.version }}</version> + </collector> + {% endfor %} + {% endif %} +</cflowd> + diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/filter_log.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/filter_log.j2 new file mode 100644 index 0000000000000000000000000000000000000000..7ab3675a89a19a00aa2ff97342c90e8969fa8e11 --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/filter_log.j2 @@ -0,0 +1,18 @@ + +<filter xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + {% if pe_filter_logs is defined %} + {% for log in pe_filter_logs %} + <log alu:operation="replace"> + <log-id>{{ log.id }}</log-id> + <description>{{ log.description }}</description> + <destination> + {% if log.destination == 'syslog' %} + <syslog> + <name>1</name> + </syslog> + {% endif %} + </destination> + </log> + {% endfor %} + {% endif %} +</filter> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/filters/fw_filters.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/filters/fw_filters.j2 index 410f156b2359fb8bd3ce701b65e94689ff90d529..4b804948c8cd8419f5c45cbe29e2be24986b861d 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/filters/fw_filters.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/filters/fw_filters.j2 @@ -109,7 +109,7 @@ {% endif %} {% endif %} {# Case when only need to match on protocol, e.g. PIM #} - {% if term.from.protocol is defined and term.from.protocol == 'pim' %} + {% if term.from.protocol is defined and term.from.protocol in ['pim', '58'] %} <entry> <entry-id>{{ ns3.entry_id }}</entry-id> <description>{{ term.name }}</description> @@ -221,7 +221,7 @@ <next-header>{{ term.from.protocol }}</next-header> {% endif %} {% endif %} - {% include 'port_list_entries.j2' %} + {% include 'filters/port_list_entries.j2' %} <dst-ip> {% if filter.family == "ipv4" %} <ip-prefix-list>{{term.from.dst_prefix_list[loop.index0]}}</ip-prefix-list> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/as_paths.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/as_paths.j2 new file mode 100644 index 0000000000000000000000000000000000000000..fadb9c5b01a5b69c57cd13877f0c9b4d86dea62a --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/as_paths.j2 @@ -0,0 +1,6 @@ + {% for as_path in as_paths_obj %} + <as-path alu:operation="replace"> + <name>{{ as_path.name }}</name> + <expression>{{ as_path.expression}}</expression> + </as-path> + {% endfor %} diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/communities.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/communities.j2 new file mode 100644 index 0000000000000000000000000000000000000000..631ddacf38c264784038e969961227f8a09f186c --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/communities.j2 @@ -0,0 +1,8 @@ + {% for community in communities_obj %} + <community alu:operation="replace"> + <name>{{ community.name }}</name> + <member> + <member>{{ community.member }}</member> + </member> + </community> + {% endfor %} diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_options.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_options.j2 new file mode 100644 index 0000000000000000000000000000000000000000..bb4790c644b63d38021a989f56870478946505b2 --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_options.j2 @@ -0,0 +1,30 @@ + <policy-options xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + {% if nokia_po_prefix_lists is defined %} + {% with prefix_lists_obj=nokia_po_prefix_lists %} + {% include 'policy_options/prefix_lists.j2' %} + {% endwith %} + {% endif %} + + {# Communities #} + {% if nokia_po_communities is defined %} + {% with communities_obj=nokia_po_communities %} + {% include 'policy_options/communities.j2' %} + {% endwith %} + {% endif %} + + {# AS paths #} + {% if nokia_po_as_paths is defined %} + {% with as_paths_obj=nokia_po_as_paths %} + {% include 'policy_options/as_paths.j2' %} + {% endwith %} + {% endif %} + + {# Policy statements #} + {% if nokia_po_policy_statements is defined %} + {% with policy_obj=nokia_po_policy_statements %} + {% include 'policy_options/policy_statements.j2' %} + {% endwith %} + {% endif %} + + </policy-options> + diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_statements.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_statements.j2 new file mode 100644 index 0000000000000000000000000000000000000000..95126f78838203c9bce99458cee179a0a87f5f75 --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_statements.j2 @@ -0,0 +1,66 @@ + {% for pol in policy_obj %} + <policy-statement alu:operation="replace"> + <name>{{ pol.name }}</name> + <entry-type>{{ pol.entry_type }}</entry-type> + {% for entry in pol.entries %} + {% if pol.entry_type == 'named' %} + <named-entry> + {% endif %} + <entry-name>{{ entry.name }}</entry-name> + {% if entry.from is defined %} + <from> + {% if entry.from.as_path is defined %} + <as-path> + {% if entry.from.as_path.name is defined %} + <name>{{ entry.from.as_path.name }}</name> + {% endif %} + {% if entry.from.as_path.length is defined %} + <length> + <value>{{ entry.from.as_path.length }}</value> + </length> + {% endif %} + </as-path> + {% endif %} + {% if entry.from.prefix_list is defined %} + {% for pl in entry.from.prefix_list %} + <prefix-list>{{ pl }}</prefix-list> + {% endfor %} + {% endif %} + {% if entry.from.community is defined %} + <community> + <name>{{ entry.from.community }}</name> + </community> + {% endif %} + {% if entry.from.origin_validation_state is defined %} + <origin-validation-state>{{ entry.from.origin_validation_state }}</origin-validation-state> + {% endif %} + {% if entry.from.protocol is defined %} + {% for proto in entry.from.protocol %} + <protocol> + <name>{{ proto }}</name> + </protocol> + {% endfor %} + {% endif %} + </from> + {% endif %} + <action> + <action-type>{{ entry.action_type }}</action-type> + {% if entry.action is defined %} + {% for action_item in entry.action %} + {% for act_k, act_v in action_item.items() %} + {% if act_k == "community_add" %} + <community> + <add>{{ act_v }}</add> + </community> + {% else %} + <{{ act_k | replace("_", "-") }}>{{ act_v }}</{{act_k | replace("_", "-") }}> + {% endif %} + {% endfor %} + {% endfor %} + {% endif %} + </action> + </named-entry> + {% endfor %} + </policy-statement> + + {% endfor %} diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/prefix_lists.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/prefix_lists.j2 new file mode 100644 index 0000000000000000000000000000000000000000..507986e60983c0445d2110328584695d67b2b70a --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/prefix_lists.j2 @@ -0,0 +1,15 @@ + {% for prefix_list in prefix_lists_obj %} + <prefix-list alu:operation="replace"> + <name>{{ prefix_list.name }}</name> + {% for prefix in prefix_list.prefixes %} + <prefix> + <ip-prefix>{{ prefix.ip }}</ip-prefix> + <type>{{ prefix.type }}</type> + {% if prefix.type == 'range' %} + <start-length>{{ prefix.range_start_length }}</start-length> + <end-length>{{ prefix.range_end_length }}</end-length> + {% endif %} + </prefix> + {% endfor %} + </prefix-list> + {% endfor %} diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/base_static_routes.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/base_static_routes.j2 index 74f967d4810de1f088c9b123a1c192bb07af7ec9..3fc1919ea6b5275211dda574a0b7eb4bb73d8cb8 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/base_static_routes.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/base_static_routes.j2 @@ -1,4 +1,3 @@ - <static-routes xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> {% if router_role == 'pe' %} {% with static_routes_obj=nokia_pe_static_routes %} {% include 'router/static_routes.j2' %} @@ -8,5 +7,4 @@ {% include 'router/static_routes.j2' %} {% endwith %} {% endif %} - </static-routes> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 index 0ed7821cfb2b07cc1d10a36b1fe8d3990477f219..cf0811e51d32cda103612fe9a97aac280b29c7f4 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 @@ -3,17 +3,18 @@ {% with bgp_base_obj=pe_bgp_base, bgp_context='bgp_base' %} {% include 'router/bgp_base.j2' %} {% endwith %} - {% with bgp_obj=pe_bgp_tools %} + {% with bgp_obj=pe_bgp_tools, bgp_group_context='bgp_base' %} {% include "router/bgp_group.j2" %} {% include "router/bgp_neighbor.j2" %} {% endwith %} - {% with bgp_obj=pe_bgp_internal %} + {% with bgp_obj=pe_bgp_internal, bgp_group_context='bgp_base' %} {% include "router/bgp_group.j2" %} {% endwith %} {% else %} - {% with bgp_base_obj=p_bgp_base, bgp_obj=p_bgp_internal, bgp_context='bgp_base' %} - {% include 'router/bgp_base' %} - {% include 'router/bgp_group' %} + {% with bgp_base_obj=p_bgp_base, bgp_obj=p_bgp_internal, bgp_context='bgp_base', + bgp_group_context='bgp_base' %} + {% include 'router/bgp_base.j2' %} + {% include 'router/bgp_group.j2' %} {% endwith %} {% endif %} </bgp> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp_base.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp_base.j2 index 965c97b04b538bae743600c6fae9a6a095daedc1..791298633cbf4c9e028cd7c4c2f5327c1ee45545 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp_base.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp_base.j2 @@ -1,8 +1,10 @@ {% if bgp_context == 'vprn' %} {% if bgp_base_obj.families is defined %} + <family> {% for fam in bgp_base_obj.families %} <{{ fam }}>true</{{ fam }}> {% endfor %} + </family> {% endif %} {% endif %} {% if bgp_base_obj.best_path_selection is defined %} @@ -23,9 +25,12 @@ {% for nhr in bgp_base_obj.next_hop_resolution.shortcut_tunnel %} <family> <family-type>{{ nhr.type }}</family-type> + {% if nhr.resolution_filter is defined %} + <resolution>filter</resolution> <resolution-filter> <{{ nhr.resolution_filter }}>true</{{ nhr.resolution_filter }}> </resolution-filter> + {% endif %} </family> {% endfor %} </shortcut-tunnel> diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/pim.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/pim.j2 index 9846452598fdd7fe7211cc7fee6e04d6fc00aca5..ccf8e8d57cb5a95281b18fc5c36c8b3adcd6255e 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/pim.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/pim.j2 @@ -1,3 +1,4 @@ + <pim xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> <rp> <ipv4> @@ -27,3 +28,4 @@ <interface-name>system</interface-name> </interface> </pim> + diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/router_base.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/router_base.j2 index 4ebc97d077345f82cf77a8da305e18c5a146ca68..97226c2c70f813548a66d850f388b5cc605b6850 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/router_base.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/router_base.j2 @@ -42,4 +42,10 @@ {% include 'router/bgp.j2' %} {% include 'router/isis.j2' %} {% include 'router/pim.j2' %} + {% if router_role == 'pe' %} + {% include 'router/flowspec.j2' %} + {% include 'router/ldp.j2' %} + {% include 'router/rpki.j2' %} + {% endif %} </router> + diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/service_vprn.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/service_vprn.j2 new file mode 100644 index 0000000000000000000000000000000000000000..4d8a57d9b55922e0098b0e67e37a81b3d0aeec54 --- /dev/null +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/service_vprn.j2 @@ -0,0 +1,12 @@ + +<service xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + <md-auto-id> + <service-id-range alu:operation="replace"> + <start>{{ pe_service.md_auto_id.service_id_range.start | default('10001') }}</start> + <end>{{ pe_service.md_auto_id.service_id_range.end | default('19999') }}</end> + </service-id-range> + </md-auto-id> + {% include 'router/vprn.j2' %} +</service> + {#{% include 'ip_prefix_list.j2' %}#} +