Skip to content

Commit 9a868c9

Browse files
authored
[muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table (sonic-net#171)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "closes #xxxx", "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related issue when the PR is merged. If you are adding/modifying/removing any command or utility script, please also make sure to add/modify/remove any unit tests from the tests directory as appropriate. If you are modifying or removing an existing 'show', 'config' or 'sonic-clear' subcommand, or you are adding a new subcommand, please make sure you also update the Command Line Reference Guide (doc/Command-Reference.md) to reflect your changes. Please provide the following information: --> #### What I did xcvrd will now move the `status` field from the TRANSCEIVER_STATUS table to the TRANSCEIVER_STATUS_SW table. This is being done via the below PRs [Update CMIS diagnostics monitoring HLD with TRANSCEIVER_STATUS_SW table by mihirpat1 · Pull Request sonic-net#1964 · sonic-net/SONiC](sonic-net/SONiC#1964) [[xcvrd] Re-organize transceiver DOM and STATUS tables by mihirpat1 · Pull Request sonic-net#604 · sonic-net/sonic-platform-daemons](sonic-net/sonic-platform-daemons#604) Therefore, the corresponding CLIs that rely on the TRANSCEIVER_STATUS table for retrieving transceiver presence need to be changed. However, a more robust method to retrieve transceiver presence is by checking if the TRANSCEIVER_INFO table is present. Thus, the relevant code change will be made to address this. #### How I did it The CLI handler now looks at the TRANSCEIVER_INFO table to find transceiver presence #### How to verify it No change in output when command is executed after putting the change manaully ``` admin@sonic:~$ show mux grpc mux Port Direction Presence PeerDirection ConnectivityState ---------- ----------- ---------- --------------- ------------------- Ethernet4 unknown True unknown unknown Ethernet8 unknown True unknown unknown Ethernet12 unknown True unknown unknown Ethernet16 unknown True unknown unknown Ethernet20 unknown True unknown unknown Ethernet24 unknown True unknown unknown Ethernet28 unknown True unknown unknown ``` For the case where TRANSCEIVER_INFO table is missing by manually deleteing it for example on Port Ethernet4 ``` admin@sonic:~$ redis-cli -n 6 DEL "TRANSCEIVER_INFO|Ethernet4" (integer) 1 admin@sonic:~$ show mux grpc mux Port Direction Presence PeerDirection ConnectivityState ---------- ----------- ---------- --------------- ------------------- Ethernet4 standby False standby READY Ethernet8 standby True standby READY ``` #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed) MSFT ADO - 32337615
1 parent bf8cb1f commit 9a868c9

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

show/muxcable.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):
21772177
mux_info_full_dict[asic_index] = state_db[asic_index].get_all(
21782178
state_db[asic_index].STATE_DB, 'MUX_CABLE_INFO|{}'.format(port))
21792179
trans_info_full_dict[asic_index] = state_db[asic_index].get_all(
2180-
state_db[asic_index].STATE_DB, 'TRANSCEIVER_STATUS|{}'.format(port))
2180+
state_db[asic_index].STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port)) or {}
21812181

21822182
res_dir = {}
21832183
res_dir = mux_info_full_dict[asic_index]
@@ -2186,10 +2186,9 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):
21862186
mux_info_dict["grpc_connection_status"] = res_dir.get("grpc_connection_status", None)
21872187

21882188
trans_dir = {}
2189-
trans_dir = trans_info_full_dict[asic_index]
2190-
2191-
status = trans_dir.get("status", "0")
2192-
presence = "True" if status == "1" else "False"
2189+
trans_dir = trans_info_full_dict.get(asic_index, None)
2190+
2191+
presence = "True" if trans_dir else "False"
21932192

21942193
mux_info_dict["presence"] = presence
21952194

tests/mock_tables/state_db.json

+17
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,23 @@
793793
"status": "67",
794794
"error": "Blocking Error|High temperature"
795795
},
796+
"TRANSCEIVER_INFO|Ethernet4": {
797+
"type": "SFP28 25G Pluggable Transceiver",
798+
"hardware_rev": "X.X",
799+
"serial": "0123456789",
800+
"manufacturer": "XXXX",
801+
"model": "XXX",
802+
"connector": "LC",
803+
"encoding": "N/A",
804+
"ext_identifier": "Power Class 1 (0.5W Max)",
805+
"ext_rateselect_compliance": "N/A",
806+
"cable_type": "Length Cable Assembly(m)",
807+
"cable_length": "0.0",
808+
"nominal_bit_rate": "0",
809+
"specification_compliance": "sm_media_interface",
810+
"vendor_date": "2021-11-19",
811+
"vendor_oui": "XX-XX-XX"
812+
},
796813
"TRANSCEIVER_STATUS|Ethernet4": {
797814
"status": "1",
798815
"error": "N/A",

tests/muxcable_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,15 @@
390390
show_muxcable_grpc_muxdirection_active_expected_all_output = """\
391391
Port Direction Presence PeerDirection ConnectivityState
392392
--------- ----------- ---------- --------------- -------------------
393-
Ethernet0 active False active READY
393+
Ethernet0 active True active READY
394394
"""
395395

396396
show_muxcable_grpc_muxdirection_active_expected_all_output_json = """\
397397
{
398398
"HWMODE": {
399399
"Ethernet0": {
400400
"Direction": "active",
401-
"Presence": "False",
401+
"Presence": "True",
402402
"PeerDirection": "active",
403403
"ConnectivityState": "READY"
404404
}

0 commit comments

Comments
 (0)