[muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table#3857
Conversation
…om TRANSCEIVER_INFO table Signed-off-by: Mihir Patel <[email protected]>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| state_db[asic_index].STATE_DB, 'MUX_CABLE_INFO|{}'.format(port)) | ||
| trans_info_full_dict[asic_index] = state_db[asic_index].get_all( | ||
| state_db[asic_index].STATE_DB, 'TRANSCEIVER_STATUS|{}'.format(port)) | ||
| state_db[asic_index].STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port)) or {} |
There was a problem hiding this comment.
what is the or condition here ?
There was a problem hiding this comment.
@vdahiya12 The or condition is just to ensure that an empty dictionary is returned rather None to avoid a crash.
show/muxcable.py
Outdated
| @@ -2187,9 +2187,8 @@ def get_grpc_cached_version_mux_direction_per_port(db, port): | |||
|
|
|||
| trans_dir = {} | |||
| trans_dir = trans_info_full_dict[asic_index] | |||
There was a problem hiding this comment.
shall we add a get call here, that would be easier to read the code below
trans_dir = trans_info_full_dict.get(asic_index, None)
|
Do we have a negative test case, to give presence as False if table not populated? please check. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR adds gRPC CLI support for transceiver presence retrieval by switching from the TRANSCEIVER_STATUS table to checking the TRANSCEIVER_INFO table.
- The CLI handler now retrieves transceiver data from TRANSCEIVER_INFO.
- Test expectations have been updated to reflect the revised presence evaluation.
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/muxcable_test.py | Expected output updated: presence for Ethernet0 changed from False to True. |
| show/muxcable.py | Modified get_grpc_cached_version_mux_direction_per_port to use TRANSCEIVER_INFO. |
Files not reviewed (1)
- tests/mock_tables/state_db.json: Language not supported
| presence = "True" if trans_dir else "False" | ||
|
|
There was a problem hiding this comment.
Ensure that the logic for determining transceiver presence correctly handles cases where the TRANSCEIVER_INFO table exists but returns an empty dictionary. If an empty dictionary should imply absence, the current condition is valid; otherwise, please adjust the condition accordingly.
| presence = "True" if trans_dir else "False" | |
| if trans_dir is not None: # Table exists | |
| presence = "True" # Treat empty dictionary as presence | |
| else: | |
| presence = "False" # Table does not exist |
|
Cherry-pick PR to msft-202412: Azure/sonic-utilities.msft#171 |
…om TRANSCEIVER_INFO table (sonic-net#3857) * [muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table Signed-off-by: Mihir Patel <[email protected]> * Using .get method to initialize trans_dir --------- Signed-off-by: Mihir Patel <[email protected]>
…ted changes (sonic-net#170) * [muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table (sonic-net#3857) * [muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table Signed-off-by: Mihir Patel <[email protected]> * Using .get method to initialize trans_dir --------- Signed-off-by: Mihir Patel <[email protected]> * Transceiver CLI changes to support DOM and STATUS table related changes Signed-off-by: Mihir Patel <[email protected]> --------- Signed-off-by: Mihir Patel <[email protected]>
…om TRANSCEIVER_INFO table (sonic-net#3857) * [muxcable] Add grpc CLI support for transceiver presence retrieval from TRANSCEIVER_INFO table Signed-off-by: Mihir Patel <[email protected]> * Using .get method to initialize trans_dir --------- Signed-off-by: Mihir Patel <[email protected]>
What I did
xcvrd will now move the
statusfield from the TRANSCEIVER_STATUS table to the TRANSCEIVER_STATUS_SW table. This is being done via the below PRsUpdate CMIS diagnostics monitoring HLD with TRANSCEIVER_STATUS_SW table by mihirpat1 · Pull Request #1964 · sonic-net/SONiC
[xcvrd] Re-organize transceiver DOM and STATUS tables by mihirpat1 · Pull Request #604 · sonic-net/sonic-platform-daemons
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
For the case where TRANSCEIVER_INFO table is missing by manually deleteing it for example on Port Ethernet4
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