From 872f0a306bb8508b1974cebdf62482a25ce7cf1a Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Sun, 4 Apr 2021 11:09:31 -0700 Subject: [PATCH] [Y-Cable] refactor get_firmware_version to comply with all vendors (#182) Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com This PR refactors the get_firmware_version output to return the following fields for each target. { "version_active": "", "version_inactive": "", "version_next": "", } Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sonic_y_cable/y_cable.py b/sonic_y_cable/y_cable.py index 04d2a92bd940..f2ae3d3c77f8 100644 --- a/sonic_y_cable/y_cable.py +++ b/sonic_y_cable/y_cable.py @@ -1224,6 +1224,10 @@ def get_firmware_version(physical_port, target): build_slot2 = chr(rev_build_lsb_slot2) + chr(rev_build_msb_slot2) version_slot2 = str(rev_major_slot2) + "." + str(rev_minor_slot2) + '''TODO: the fields with slot number as suffix are redundant and must + be removed eventually since they are covered by the fields which + have version as prefix. ''' + result["build_slot1"] = build_slot1 result["version_slot1"] = version_slot1 result["build_slot2"] = build_slot2 @@ -1235,6 +1239,14 @@ def get_firmware_version(physical_port, target): result["empty_slot1"] = True if slot_status & 0x04 else False result["empty_slot2"] = True if slot_status & 0x40 else False + version_build_slot1 = version_slot1 + build_slot1 + version_build_slot2 = version_slot2 + build_slot2 + + result["version_active"] = version_build_slot1 if slot_status & 0x01 else version_build_slot2 + result["version_inactive"] = version_build_slot2 if slot_status & 0x01 else version_build_slot1 + result["version_next"] = version_build_slot1 if slot_status & 0x02 else version_build_slot2 + + return result