Skip to content

Commit

Permalink
Reorder functions and add spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrallen committed May 25, 2021
1 parent a305336 commit 9f92c74
Showing 1 changed file with 41 additions and 40 deletions.
81 changes: 41 additions & 40 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,6 @@
CHASSIS_INFO_MODEL_FIELD = 'model'
CHASSIS_INFO_REV_FIELD = 'revision'

# Get hardware information
def get_platform_info():
"""
This function is used to get the HW info helper function
"""
from .multi_asic import get_num_asics

hw_info_dict = {}

version_info = get_sonic_version_info()

hw_info_dict['platform'] = get_platform()
hw_info_dict['hwsku'] = get_hwsku()
hw_info_dict['asic_type'] = version_info['asic_type']
hw_info_dict['asic_count'] = get_num_asics()

return hw_info_dict


def get_chassis_info():
"""
This function is used to get the Chassis serial / model / rev number
"""

chassis_info_dict = {}

try:
# Init statedb connection
db = SonicV2Connector()
db.connect(db.STATE_DB)
table = CHASSIS_INFO_TABLE.format(1)

chassis_info_dict['serial'] = db.get(db.STATE_DB, table, CHASSIS_INFO_SERIAL_FIELD)
chassis_info_dict['model'] = db.get(db.STATE_DB, table, CHASSIS_INFO_MODEL_FIELD)
chassis_info_dict['revision'] = db.get(db.STATE_DB, table, CHASSIS_INFO_REV_FIELD)
except:
pass

return chassis_info_dict


def get_localhost_info(field):
try:
Expand Down Expand Up @@ -350,6 +310,47 @@ def get_sonic_version_file():

return SONIC_VERSION_YAML_PATH


# Get hardware information
def get_platform_info():
"""
This function is used to get the HW info helper function
"""
from .multi_asic import get_num_asics

hw_info_dict = {}

version_info = get_sonic_version_info()

hw_info_dict['platform'] = get_platform()
hw_info_dict['hwsku'] = get_hwsku()
hw_info_dict['asic_type'] = version_info['asic_type']
hw_info_dict['asic_count'] = get_num_asics()

return hw_info_dict


def get_chassis_info():
"""
This function is used to get the Chassis serial / model / rev number
"""

chassis_info_dict = {}

try:
# Init statedb connection
db = SonicV2Connector()
db.connect(db.STATE_DB)
table = CHASSIS_INFO_TABLE.format(1)

chassis_info_dict['serial'] = db.get(db.STATE_DB, table, CHASSIS_INFO_SERIAL_FIELD)
chassis_info_dict['model'] = db.get(db.STATE_DB, table, CHASSIS_INFO_MODEL_FIELD)
chassis_info_dict['revision'] = db.get(db.STATE_DB, table, CHASSIS_INFO_REV_FIELD)
except:
pass

return chassis_info_dict

#
# Multi-NPU functionality
#
Expand Down

0 comments on commit 9f92c74

Please sign in to comment.