Skip to content

Commit 9f92c74

Browse files
committed
Reorder functions and add spacing
1 parent a305336 commit 9f92c74

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

src/sonic-py-common/sonic_py_common/device_info.py

+41-40
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,6 @@
3939
CHASSIS_INFO_MODEL_FIELD = 'model'
4040
CHASSIS_INFO_REV_FIELD = 'revision'
4141

42-
# Get hardware information
43-
def get_platform_info():
44-
"""
45-
This function is used to get the HW info helper function
46-
"""
47-
from .multi_asic import get_num_asics
48-
49-
hw_info_dict = {}
50-
51-
version_info = get_sonic_version_info()
52-
53-
hw_info_dict['platform'] = get_platform()
54-
hw_info_dict['hwsku'] = get_hwsku()
55-
hw_info_dict['asic_type'] = version_info['asic_type']
56-
hw_info_dict['asic_count'] = get_num_asics()
57-
58-
return hw_info_dict
59-
60-
61-
def get_chassis_info():
62-
"""
63-
This function is used to get the Chassis serial / model / rev number
64-
"""
65-
66-
chassis_info_dict = {}
67-
68-
try:
69-
# Init statedb connection
70-
db = SonicV2Connector()
71-
db.connect(db.STATE_DB)
72-
table = CHASSIS_INFO_TABLE.format(1)
73-
74-
chassis_info_dict['serial'] = db.get(db.STATE_DB, table, CHASSIS_INFO_SERIAL_FIELD)
75-
chassis_info_dict['model'] = db.get(db.STATE_DB, table, CHASSIS_INFO_MODEL_FIELD)
76-
chassis_info_dict['revision'] = db.get(db.STATE_DB, table, CHASSIS_INFO_REV_FIELD)
77-
except:
78-
pass
79-
80-
return chassis_info_dict
81-
8242

8343
def get_localhost_info(field):
8444
try:
@@ -350,6 +310,47 @@ def get_sonic_version_file():
350310

351311
return SONIC_VERSION_YAML_PATH
352312

313+
314+
# Get hardware information
315+
def get_platform_info():
316+
"""
317+
This function is used to get the HW info helper function
318+
"""
319+
from .multi_asic import get_num_asics
320+
321+
hw_info_dict = {}
322+
323+
version_info = get_sonic_version_info()
324+
325+
hw_info_dict['platform'] = get_platform()
326+
hw_info_dict['hwsku'] = get_hwsku()
327+
hw_info_dict['asic_type'] = version_info['asic_type']
328+
hw_info_dict['asic_count'] = get_num_asics()
329+
330+
return hw_info_dict
331+
332+
333+
def get_chassis_info():
334+
"""
335+
This function is used to get the Chassis serial / model / rev number
336+
"""
337+
338+
chassis_info_dict = {}
339+
340+
try:
341+
# Init statedb connection
342+
db = SonicV2Connector()
343+
db.connect(db.STATE_DB)
344+
table = CHASSIS_INFO_TABLE.format(1)
345+
346+
chassis_info_dict['serial'] = db.get(db.STATE_DB, table, CHASSIS_INFO_SERIAL_FIELD)
347+
chassis_info_dict['model'] = db.get(db.STATE_DB, table, CHASSIS_INFO_MODEL_FIELD)
348+
chassis_info_dict['revision'] = db.get(db.STATE_DB, table, CHASSIS_INFO_REV_FIELD)
349+
except:
350+
pass
351+
352+
return chassis_info_dict
353+
353354
#
354355
# Multi-NPU functionality
355356
#

0 commit comments

Comments
 (0)