From 5477c716f22d20210cb7738160e4f13e012f56ca Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local> Date: Thu, 12 Sep 2024 11:44:29 +0100 Subject: [PATCH] PE base config integrated --- .../base_config/tasks/merge_variables.yaml | 14 +++- .../bc_templates/routers/nokia/base_config.j2 | 20 ++++-- .../bc_templates/routers/nokia/cflowd.j2 | 29 ++++++++ .../bc_templates/routers/nokia/filter_log.j2 | 18 +++++ .../routers/nokia/filters/fw_filters.j2 | 4 +- .../routers/nokia/policy_options/as_paths.j2 | 6 ++ .../nokia/policy_options/communities.j2 | 8 +++ .../nokia/policy_options/policy_options.j2 | 30 +++++++++ .../nokia/policy_options/policy_statements.j2 | 66 +++++++++++++++++++ .../nokia/policy_options/prefix_lists.j2 | 15 +++++ .../nokia/router/base_static_routes.j2 | 2 - .../bc_templates/routers/nokia/router/bgp.j2 | 11 ++-- .../routers/nokia/router/bgp_base.j2 | 5 ++ .../bc_templates/routers/nokia/router/pim.j2 | 2 + .../routers/nokia/router/router_base.j2 | 6 ++ .../routers/nokia/service_vprn.j2 | 12 ++++ 16 files changed, 231 insertions(+), 17 deletions(-) create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/cflowd.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/filter_log.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/as_paths.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/communities.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_options.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/policy_statements.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/policy_options/prefix_lists.j2 create mode 100644 geant/gap_ansible/roles/bc_templates/routers/nokia/service_vprn.j2 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 fd244bc3..67f05357 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 590a0eb8..a3fc0e26 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 00000000..ef8dcc9f --- /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 00000000..7ab3675a --- /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 410f156b..4b804948 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 00000000..fadb9c5b --- /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 00000000..631ddacf --- /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 00000000..bb4790c6 --- /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 00000000..95126f78 --- /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 00000000..507986e6 --- /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 74f967d4..3fc1919e 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 0ed7821c..cf0811e5 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 965c97b0..79129863 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 98464525..ccf8e8d5 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 4ebc97d0..97226c2c 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 00000000..4d8a57d9 --- /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' %}#} + -- GitLab