From e06b861105511c55de7b9aa98e70f8f02e75d097 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Thu, 10 Apr 2025 16:25:38 +0100
Subject: [PATCH] `l2circuits` role update
- Support for Local Cross connects
- Support for VLAN-range circuits in Junos
---
geant/gap_ansible/playbooks/l2circuit.yaml | 39 ++++++++++++++++---
.../roles/l2circuits/tasks/merge_vars.yaml | 8 +++-
.../templates/juniper/deploy/l2circuit.j2 | 5 +++
.../templates/juniper/terminate/l2circuit.j2 | 5 +++
.../templates/nokia/deploy/l2circuit.j2 | 22 +++++++++--
5 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/geant/gap_ansible/playbooks/l2circuit.yaml b/geant/gap_ansible/playbooks/l2circuit.yaml
index 5f20a0fd..2d537f02 100644
--- a/geant/gap_ansible/playbooks/l2circuit.yaml
+++ b/geant/gap_ansible/playbooks/l2circuit.yaml
@@ -10,9 +10,36 @@
ansible.builtin.include_vars:
dir: /opt/ansible_inventory/geant_services/{{ subscription.product.product_type }}/{{ subscription.layer_2_circuit_service_type | upper | replace(' ', '_') }}
- - name: Include l2circuit role
- ansible.builtin.include_role:
- name: l2circuits
- loop: "{{ subscription.layer_2_circuit.layer_2_circuit_sides }}"
- loop_control:
- loop_var: l2c_side
+ - name: Configure L2circuit as Local cross connect
+ when: subscription.layer_2_circuit.layer_2_circuit_sides[0].sbp.edge_port.node.router_fqdn ==
+ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.edge_port.node.router_fqdn
+ block:
+ - name: Set vars
+ ansible.builtin.set_fact:
+ local_cross_connect: true
+ l2c_side_b_lag: "{{ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.edge_port.edge_port_name }}"
+ l2c_side_b_vlan: "{{ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.vlan_id }}"
+ l2c_side_b_gs_id: "{{ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.gs_id }}"
+ remote_partner_name: "{{ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.edge_port.partner_name }}"
+
+ - name: Include l2circuits role
+ ansible.builtin.include_role:
+ name: l2circuits
+ vars:
+ l2c_side: "{{ subscription.layer_2_circuit.layer_2_circuit_sides[0] }}"
+
+
+ - name: Configure L2circuit on 2 different nodes
+ when: subscription.layer_2_circuit.layer_2_circuit_sides[0].sbp.edge_port.node.router_fqdn !=
+ subscription.layer_2_circuit.layer_2_circuit_sides[1].sbp.edge_port.node.router_fqdn
+ block:
+ - name: Set vars
+ ansible.builtin.set_fact:
+ local_cross_connect: false
+
+ - name: Include l2circuits role
+ ansible.builtin.include_role:
+ name: l2circuits
+ loop: "{{ subscription.layer_2_circuit.layer_2_circuit_sides }}"
+ loop_control:
+ loop_var: l2c_side
diff --git a/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml b/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml
index 58958102..0cc0f129 100644
--- a/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml
+++ b/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml
@@ -1,5 +1,6 @@
---
- name: Load info for the remote l2circuit endpoint
+ when: not local_cross_connect
ansible.builtin.set_fact:
remote_side: "{{ subscription | community.general.json_query(qry) }}"
vars:
@@ -11,12 +12,17 @@
vars:
qry: "layer_2_circuit.layer_2_circuit_sides[?sbp.edge_port.node.router_fqdn == '{{ inventory_hostname }}'] | [0]"
-- name: Set partner names for the l2circuit endpoints
+- name: Set partner names for the l2circuit Local endpoint
ansible.builtin.set_fact:
local_partner_name: "{{ local_side.sbp.edge_port.partner_name }}"
+
+- name: Set partner names for the l2circuit Remote endpoint
+ when: not local_cross_connect
+ ansible.builtin.set_fact:
remote_partner_name: "{{ remote_side.sbp.edge_port.partner_name }}"
- name: Calculate SDP to use locally
+ when: not local_cross_connect
ansible.builtin.set_fact:
sdp_id: "{{ remote_side.sbp.edge_port.node.router_lo_ipv4_address |
replace(sdp_prefix_regex, '') | replace('.', '') + l2circuits_sdp_type }}"
diff --git a/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2 b/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2
index a642a9b3..10c3fac6 100644
--- a/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2
+++ b/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2
@@ -9,7 +9,12 @@ set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} output-vlan-
set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} vlan-id-range {{ subscription.layer_2_circuit.vlan_range_lower_bound }}-{{ subscription.layer_2_circuit.vlan_range_upper_bound }}
{% endif %}
+{% if not local_cross_connect %}
set protocols l2circuit neighbor {{ remote_side.sbp.edge_port.node.router_lo_ipv4_address }} interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} virtual-circuit-id {{ l2circuits_l2c_vcid }}
set protocols l2circuit neighbor {{ remote_side.sbp.edge_port.node.router_lo_ipv4_address }} interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} control-word
set protocols l2circuit neighbor {{ remote_side.sbp.edge_port.node.router_lo_ipv4_address }} interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} mtu {{ service_mtu.juniper }}
+{% else %}
+set protocols l2circuit local-switching interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} end-interface {{ l2c_side_b_lag }}.{{ l2c_side_b_vlan }}
+set protocols l2circuit local-switching interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} ignore-mtu-mismatch
+{% endif %}
diff --git a/geant/gap_ansible/roles/l2circuits/templates/juniper/terminate/l2circuit.j2 b/geant/gap_ansible/roles/l2circuits/templates/juniper/terminate/l2circuit.j2
index 067d5114..701610d6 100644
--- a/geant/gap_ansible/roles/l2circuits/templates/juniper/terminate/l2circuit.j2
+++ b/geant/gap_ansible/roles/l2circuits/templates/juniper/terminate/l2circuit.j2
@@ -1,2 +1,7 @@
+{% if not local_cross_connect %}
delete protocols l2circuit neighbor {{ remote_side.sbp.edge_port.node.router_lo_ipv4_address }} interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }}
delete interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }}
+{% else %}
+delete protocols l2circuit local-switching interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} ignore-mtu-mismatch
+delete protocols l2circuit local-switching interface {{ l2circuits_lag_name }}.{{ l2circuits_vlan }} end-interface {{ l2c_side_b_lag }}.{{ l2c_side_b_vlan }}
+{% endif %}
diff --git a/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2 b/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2
index 6d8567ba..55bb3573 100644
--- a/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2
+++ b/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2
@@ -14,16 +14,20 @@
</connection-profile>
{% endif %}
+{% set csn = '#'+l2circuits_custom_service_name|replace(' ', '_') if l2circuits_custom_service_name|length > 0 %}
+
+
<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">
<epipe alu:operation="replace">
- <service-name >EPIPE:{{ l2circuits_custom_service_name | replace(' ', '_') }}:{{ l2circuits_l2c_vcid }}</service-name>
+ <service-name>EPIPE:{{ l2circuits_custom_service_name | replace(' ', '_') }}:{{ l2circuits_l2c_vcid }}</service-name>
<admin-state>enable</admin-state>
- <description>SRV_L2CIRCUIT CUSTOMER {{ local_partner_name | upper }} {{ remote_partner_name | upper }} #{{ l2circuits_custom_service_name | replace(' ', '_') }} ${{ local_side.sbp.gs_id }}</description>
+ <description>SRV_L2CIRCUIT CUSTOMER {{ local_partner_name | upper }} {{ remote_partner_name | upper }} {{ csn | replace(' ', '_') if csn is defined }} ${{ local_side.sbp.gs_id }}</description>
<service-id>{{ l2circuits_l2c_vcid }}</service-id>
<customer>1</customer>
- <vpn-id>{{ l2circuits_l2c_vcid }}</vpn-id>
<service-mtu>{{ service_mtu.nokia }}</service-mtu>
+ {% if not local_cross_connect %}
<ignore-l2vpn-mtu-mismatch>false</ignore-l2vpn-mtu-mismatch>
+ <vpn-id>{{ l2circuits_l2c_vcid }}</vpn-id>
<spoke-sdp>
<sdp-bind-id>{{ sdp_id }}:{{ l2circuits_l2c_vcid }}</sdp-bind-id>
<admin-state>enable</admin-state>
@@ -33,6 +37,7 @@
<signaling>true</signaling>
</pw-status>
</spoke-sdp>
+ {% endif %}
<sap>
<description>{{ local_partner_name | upper }}:{{ l2circuits_vlan }}:{{ local_side.sbp.gs_id }}</description>
{% if l2circuits_l2c_type == 'Ethernet' %}
@@ -42,6 +47,17 @@
{% endif %}
<admin-state>enable</admin-state>
</sap>
+ {% if local_cross_connect %}
+ <sap>
+ <description>{{ remote_partner_name | upper }}:{{ l2c_side_b_vlan }}:{{ l2c_side_b_gs_id }}</description>
+ {% if l2circuits_l2c_type == 'Ethernet' %}
+ <sap-id>{{ l2c_side_b_lag }}:{{ l2c_side_b_vlan }}</sap-id>
+ {% else %}
+ <sap-id>{{ l2c_side_b_lag }}:cp-{{ l2c_side_b_vlan }}</sap-id>
+ {% endif %}
+ <admin-state>enable</admin-state>
+ </sap>
+ {% endif %}
</epipe>
</service>
--
GitLab