Skip to content

Commit

Permalink
add comments to describe the usage of functions to judge the port type
Browse files Browse the repository at this point in the history
Signed-off-by: Kebo Liu <kebol@nvidia.com>
  • Loading branch information
keboliu committed Jun 22, 2022
1 parent 8e11f59 commit e8eacb3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,19 @@ def is_sfp_present(port_name):
return bool(presence)


# Determine whether it is a RJ45 port
# Below defined two flavors of functions to determin whether a port is a RJ45 port.
# They serve different types of SFP utilities. One type of SFP utility consume the
# info stored in the STATE_DB, these utilities shall call 'is_rj45_port_from_db'
# to judge the port type. Another type of utilities will call the platform API
# directly to access SFP, for them shall use 'is_rj45_port_from_api'.
def is_rj45_port_from_db(port_name, db):
# Determine whether a port is a RJ45 port by checking TRANSCEIVER_INFO in STATE_DB
intf_type = db.get(db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port_name), 'type')
return intf_type == RJ45_PORT_TYPE


def is_rj45_port_from_api(port_name):
# Determine whether a port is a RJ45 port by calling platform API.
physical_port = logical_port_to_physical_port_index(port_name)
sfp = platform_chassis.get_sfp(physical_port)

Expand Down

0 comments on commit e8eacb3

Please sign in to comment.