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
new file mode 100644
index 0000000000000000000000000000000000000000..d338efa4717b50fb34d19411273a2364a8523367
--- /dev/null
+++ b/geant/gap_ansible/roles/iptrunk_checks/tasks/check_optical_levels.yaml
@@ -0,0 +1,47 @@
+---
+###############################################################################################################
+# The playbook does the following:
+#
+#
+# - Runs the command 'show interfaces diagnostics optics {{ interface }} | no-more' and gets the json output
+# - From json output it retrieves the apporpriate metrics for optical levels
+# - Saves the metrics in relevant variable names
+###############################################################################################################
+
+- name: Get Junos attributes for optical levels of interface "{{ item }}"
+ when: local_side.iptrunk_side_node.vendor == "juniper"
+ block:
+ - name: Run Juniper Optical info
+ junipernetworks.junos.junos_command:
+ commands: "show interfaces diagnostics optics {{ item }} | no-more"
+ # display: json
+ register: optical_status
+
+ - name: Show optical levels on Juniper interface "{{ item }}"
+ ansible.builtin.debug:
+ msg: "{{ optical_status }}"
+
+- name: Get Nokia optical levels on port "{{ item }}"
+ when: local_side.iptrunk_side_node.vendor == "nokia"
+ block:
+ - name: Prepare the connector var
+ ansible.builtin.set_fact:
+ connector: "{{ item | regex_search('[1-9]/[1-9]/c[1-9]+') }}"
+
+ - name: Run Nokia show command
+ ansible.netcommon.netconf_rpc:
+ rpc: action
+ xmlns: "urn:ietf:params:xml:ns:yang:1"
+ content: |
+ <global-operations xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global">
+ <md-cli-raw-command>
+ <md-cli-input-line>show port {{ connector }} optical</md-cli-input-line>
+ </md-cli-raw-command>
+ </global-operations>
+ display: json
+ register: output
+
+ - name: Show optical levels on Nokia port "{{ item }}"
+ ansible.builtin.debug:
+ # msg: "{{ output }}"
+ msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}"
diff --git a/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml b/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml
index f5da18ba9958c35a3c204a28b13bd3e3c772cc36..cdc6108fd05d3c81467a54f86f1f123ae35e73c5 100644
--- a/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml
+++ b/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml
@@ -20,6 +20,12 @@
vars:
query: "iptrunk.iptrunk_sides[?iptrunk_side_node.router_fqdn == '{{ inventory_hostname }}'] | [0]"
+- name: Load remote info
+ ansible.builtin.set_fact:
+ remote_side: "{{ wfo_trunk_json | community.general.json_query(query) }}"
+ vars:
+ query: "iptrunk.iptrunk_sides[?iptrunk_side_node.router_fqdn != '{{ inventory_hostname }}'] | [0]"
+
- name: Set ansible_host to terminal server when router is offline
ansible.builtin.set_fact:
ansible_host: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_site.site_ts_address }}"
@@ -39,3 +45,8 @@
- name: Check ping
ansible.builtin.include_tasks: check_trunk_interface.yaml
when: check == "ping"
+
+- name: Check optical levels
+ ansible.builtin.include_tasks: check_optical_levels.yaml
+ when: check == "optical"
+ loop: "{{ local_side.iptrunk_side_ae_members }}"
diff --git a/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml b/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml
index 3b5859461aad26f49d859f79fc7924a94ae32fa6..1e93aab6f44d00df761d3dedf9b9b4bc7c13d576 100644
--- a/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml
+++ b/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml
@@ -5,6 +5,8 @@
checks:
- isis
- ping
+ - lacp
+ - optical
wfo_trunk: "{{ wfo_ip_trunk_json }}"
@@ -19,7 +21,7 @@ trunks:
common:
description: "{{ wfo_trunk.iptrunk.iptrunk_description }}"
speed: "{{ wfo_trunk.iptrunk.iptrunk_speed }}"
- is_leased_line: false ## Fix it to use iptrunk_type
+ is_leased_line: false ## FIX: it to use iptrunk_type
isis_metric: "{{ wfo_trunk.iptrunk.iptrunk_isis_metric }}"
minimum_links: "{{ wfo_trunk.iptrunk.iptrunk_minimum_links }}"
nodeA: