From 97d55e9f08c84aacfa15e6cbe2d04b7aeee0c14d Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342.local>
Date: Thu, 4 Jul 2024 20:06:19 +0100
Subject: [PATCH] Nokia optical parser updated

---
 .../roles/iptrunk_checks/tasks/check_optical_levels.yaml    | 6 +-----
 .../iptrunk_checks/templates/sros_show_port_optical.yaml    | 6 +++---
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/geant/gap_ansible/roles/iptrunk_checks/tasks/check_optical_levels.yaml b/geant/gap_ansible/roles/iptrunk_checks/tasks/check_optical_levels.yaml
index 6f3b3d19..87170921 100644
--- a/geant/gap_ansible/roles/iptrunk_checks/tasks/check_optical_levels.yaml
+++ b/geant/gap_ansible/roles/iptrunk_checks/tasks/check_optical_levels.yaml
@@ -57,7 +57,7 @@
 
     - name: Parse SROS port optical output
       ansible.utils.cli_parse:
-        text: "{{ out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'] }}"
+        text: "{{ out.stdout }}"
         parser:
           name: ansible.netcommon.native
           template_path: "{{ role_path }}/templates/sros_show_port_optical.yaml"
@@ -68,7 +68,3 @@
         ae_result: "{{ ae_result | combine({item.key: item.value}) }}"
       with_items:
         - { key: "{{ ae_member.interface_name }}", value: "{{ lanes }}" }
-
-    - name: Empty lanes variable for the next cycle
-      ansible.builtin.set_fact:
-        lanes: []
diff --git a/geant/gap_ansible/roles/iptrunk_checks/templates/sros_show_port_optical.yaml b/geant/gap_ansible/roles/iptrunk_checks/templates/sros_show_port_optical.yaml
index a8754bac..c2511373 100644
--- a/geant/gap_ansible/roles/iptrunk_checks/templates/sros_show_port_optical.yaml
+++ b/geant/gap_ansible/roles/iptrunk_checks/templates/sros_show_port_optical.yaml
@@ -1,8 +1,8 @@
 ---
 - example: "    1              -              73.2              1.67              1.43"
-  getval: '\s+(?P<lane_id>\d)\s+-\s+(?P<tx_bias_ma>\d+(\.\d+)?)\s+(?P<tx_power_dbm>\d+(\.\d+)?)\s+(?P<rx_power_dbm>\d+(\.\d+)?)'
+  getval: '^\s+(?P<lane_id>\d)\s+-\s+(?P<tx_bias_ma>\d{1,3}(\.\d)?)\s+(?P<tx_power_dbm>-?\d(\.\d{1,2})(-?\d\.\d{1,2})?!?)\s+(?P<rx_power_dbm>-?\d(\.\d{1,2})(-?\d\.\d{1,2})?!?)\s+'
   result:
     "Lane {{ lane_id }}":
       TX_bias_mA: "{{ tx_bias_ma }}"
-      TX_power_dBm: "{{ tx_power_dbm }}"
-      rx_power_dBm: "{{ rx_power_dbm }}"
+      TX_PWR_dBm: "{{ tx_power_dbm }}"
+      RX_PWR_dBm: "{{ rx_power_dbm }}"
-- 
GitLab