From 41f331f6b85b15b76ba6ae925fbb78fd0a0bf914 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 8 May 2025 15:05:30 +0100 Subject: [PATCH] Changes around `ims_service_name` If `custom_service_name` is passed from GSO, use this; else construct `ims_service_name` according to the agreed algorithm, and use in the service description after `#`. - `partners_sorted` - always use partners names sorted in alphabetical order in the service description. --- .../roles/l2circuits/tasks/merge_vars.yaml | 34 +++++++++++++++++-- .../templates/juniper/deploy/l2circuit.j2 | 2 +- .../templates/nokia/deploy/l2circuit.j2 | 7 ++-- .../templates/nokia/terminate/l2circuit.j2 | 2 +- .../roles/l2circuits/vars/main.yml | 2 +- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml b/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml index 0cc0f129..62f4834d 100644 --- a/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml +++ b/geant/gap_ansible/roles/l2circuits/tasks/merge_vars.yaml @@ -14,12 +14,42 @@ - name: Set partner names for the l2circuit Local endpoint ansible.builtin.set_fact: - local_partner_name: "{{ local_side.sbp.edge_port.partner_name }}" + local_partner_name: "{{ local_side.sbp.edge_port.partner_name | upper }}" - 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 }}" + remote_partner_name: "{{ remote_side.sbp.edge_port.partner_name | upper }}" + +- name: Set partners combination for the service description + when: not local_cross_connect + ansible.builtin.set_fact: + partners_sorted: "{{ [local_partner_name, remote_partner_name] | sort | join(' ') }}" + +- name: Set IMS service name to subscription custom_service_name if it is defined + when: subscription.layer_2_circuit.custom_service_name is not none + ansible.builtin.set_fact: + ims_service_name: "{{ subscription.layer_2_circuit.custom_service_name }}" + +- name: Calculate IMS service name + when: subscription.layer_2_circuit.custom_service_name is none + block: + - name: Set local and remote site names + ansible.builtin.set_fact: + local_site_name: "{{ local_side.sbp.edge_port.node.router_site.site_name }}" + remote_site_name: "{{ remote_side.sbp.edge_port.node.router_site.site_name }}" + + - name: Sort site names alphabetically + ansible.builtin.set_fact: + site_names_sorted: "{{ [local_site_name, remote_site_name] | sort | join('-') }}" + + - name: Extract last 5 digits from the GS-ID + ansible.builtin.set_fact: + gsid: "{{ local_side.sbp.gs_id[-5:] | join('') }}" + + - name: Put IMS name together + ansible.builtin.set_fact: + ims_service_name: "{{ site_names_sorted + '-' + gsid }}" - name: Calculate SDP to use locally when: not local_cross_connect 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 10c3fac6..286b42c8 100644 --- a/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2 +++ b/geant/gap_ansible/roles/l2circuits/templates/juniper/deploy/l2circuit.j2 @@ -1,4 +1,4 @@ -set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} description "SRV_L2CIRCUIT CUSTOMER {{ local_partner_name | upper }} {{ remote_partner_name | upper }} #{{ l2circuits_custom_service_name | replace(' ', '_') }} ${{ local_side.sbp.gs_id }}" +set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} description "SRV_L2CIRCUIT CUSTOMER {{ patners_sorted }} #{{ ims_service_name }} ${{ local_side.sbp.gs_id }}" set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} encapsulation vlan-ccc set interfaces {{ l2circuits_lag_name }} unit {{ l2circuits_vlan }} family ccc {% if l2circuits_l2c_type == 'Ethernet' %} 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 55bb3573..69b51aaf 100644 --- a/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2 +++ b/geant/gap_ansible/roles/l2circuits/templates/nokia/deploy/l2circuit.j2 @@ -1,4 +1,3 @@ -{#{% if l2circuits_is_standalone_run %}#} <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> @@ -14,14 +13,12 @@ </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:{{ ims_service_name }}:{{ l2circuits_l2c_vcid }}</service-name> <admin-state>enable</admin-state> - <description>SRV_L2CIRCUIT CUSTOMER {{ local_partner_name | upper }} {{ remote_partner_name | upper }} {{ csn | replace(' ', '_') if csn is defined }} ${{ local_side.sbp.gs_id }}</description> + <description>SRV_L2CIRCUIT CUSTOMER {{ partners_sorted }} #{{ ims_service_name }} ${{ local_side.sbp.gs_id }}</description> <service-id>{{ l2circuits_l2c_vcid }}</service-id> <customer>1</customer> <service-mtu>{{ service_mtu.nokia }}</service-mtu> diff --git a/geant/gap_ansible/roles/l2circuits/templates/nokia/terminate/l2circuit.j2 b/geant/gap_ansible/roles/l2circuits/templates/nokia/terminate/l2circuit.j2 index eb28e6a9..798ac868 100644 --- a/geant/gap_ansible/roles/l2circuits/templates/nokia/terminate/l2circuit.j2 +++ b/geant/gap_ansible/roles/l2circuits/templates/nokia/terminate/l2circuit.j2 @@ -11,7 +11,7 @@ <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="delete"> - <service-name>EPIPE:{{ l2circuits_custom_service_name | replace(' ', '_') }}:{{ l2circuits_l2c_vcid }}</service-name> + <service-name>EPIPE:{{ ims_service_name }}:{{ l2circuits_l2c_vcid }}</service-name> </epipe> </service> diff --git a/geant/gap_ansible/roles/l2circuits/vars/main.yml b/geant/gap_ansible/roles/l2circuits/vars/main.yml index 9380163e..a3ec77d2 100644 --- a/geant/gap_ansible/roles/l2circuits/vars/main.yml +++ b/geant/gap_ansible/roles/l2circuits/vars/main.yml @@ -9,4 +9,4 @@ l2circuits_lag_name: "{{ l2c_side.sbp.edge_port.edge_port_name }}" l2circuits_vlan: "{{ l2c_side.sbp.vlan_id }}" l2circuits_l2c_type: "{{ subscription.layer_2_circuit.layer_2_circuit_type }}" l2circuits_l2c_vcid: "{{ subscription.layer_2_circuit.virtual_circuit_id }}" -l2circuits_custom_service_name: "{{ subscription.layer_2_circuit.custom_service_name }}" +# l2circuits_custom_service_name: "{{ subscription.layer_2_circuit.custom_service_name }}" -- GitLab