Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skr31 committed Jul 3, 2024
1 parent dad1032 commit cf212d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
PlatformDataProvider = None

from sonic_py_common.general import check_output_pipe
from sonic_platform.device_data import DeviceDataManager
from tabulate import tabulate

COMPONENT_VERSIONS_FILE = "/etc/mlnx/component-versions"
Expand Down Expand Up @@ -120,13 +121,6 @@ def format_output_table(table):
return tabulate(table, HEADERS)


def get_simx_version():
"SIMX": [["lspci", "-vv"], ["grep", "SimX"], "([0-9]+\\.[0-9]+-[0-9]+)"]
version = check_output_pipe(["lspci", "-vv"], ["grep", "SimX"])
parsed_version = re.search("([0-9]+\\.[0-9]+-[0-9]+)", version)
return parsed_version.group(1) if parsed_version else "N/A"


def main():

if os.getuid() != 0:
Expand All @@ -143,8 +137,8 @@ def main():
output_table.append([comp, compiled_versions[comp], actual])

# Handle if SIMX
simx_actual_ver = get_simx_version()
if simx_actual_ver:
if DeviceDataManager.is_simx_platform():
simx_actual_ver = DeviceDataManager.get_simx_version()
output_table.append(["SIMX", simx_compiled_ver, simx_actual_ver])
platform_versions = UNAVAILABLE_PLATFORM_VERSIONS
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import glob
import os
import time
import re

from . import utils
from sonic_py_common.general import check_output_pipe

DEFAULT_WD_PERIOD = 65535

Expand Down Expand Up @@ -160,6 +162,13 @@ def is_simx_platform(cls):
platform_name = cls.get_platform_name()
return platform_name and 'simx' in platform_name

@classmethod
@utils.read_only_cache()
def get_simx_version(cls):
version = check_output_pipe(["lspci", "-vv"], ["grep", "SimX"])
parsed_version = re.search("([0-9]+\\.[0-9]+-[0-9]+)", version)
return parsed_version.group(1) if parsed_version else "N/A"

@classmethod
@utils.read_only_cache()
def get_fan_drawer_count(cls):
Expand Down

0 comments on commit cf212d0

Please sign in to comment.