Skip to content

Commit

Permalink
[Y-Cable] refactor get_firmware_version to comply with all vendors (s…
Browse files Browse the repository at this point in the history
…onic-net#182)

Signed-off-by: vaibhav-dahiya [email protected]
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 <[email protected]>
  • Loading branch information
vdahiya12 authored Apr 4, 2021
1 parent cc162d6 commit 872f0a3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sonic_y_cable/y_cable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down

0 comments on commit 872f0a3

Please sign in to comment.