Skip to content

Commit

Permalink
[Author]:[email protected] [Jira ID]:N/A [Description]:fix the m…
Browse files Browse the repository at this point in the history
…erge conflict with PDDF
  • Loading branch information
nicwu-cel committed May 10, 2022
1 parent 5b3cb0b commit b725940
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
4 changes: 2 additions & 2 deletions platform/pddf/i2c/utils/pddf_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import shutil
import subprocess
import sys
from sonic_py_common import device_info

import pddfparse

PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
Expand Down Expand Up @@ -139,7 +139,7 @@ def driver_check():

def get_path_to_device():
# Get platform and hwsku
(platform, hwsku) = device_info.get_platform_and_hwsku()
(platform, hwsku) = pddf_obj.get_platform_and_hwsku()

# Load platform module from source
platform_path = "/".join([PLATFORM_ROOT_PATH, platform])
Expand Down
28 changes: 26 additions & 2 deletions platform/pddf/i2c/utils/pddfparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sys
import time
import unicodedata
from sonic_py_common import device_info

bmc_cache = {}
cache = {}
Expand All @@ -34,7 +33,7 @@
class PddfParse():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
platform, hwsku = device_info.get_platform_and_hwsku()
platform, hwsku = self.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+platform, "/usr/share/sonic/platform")

try:
Expand All @@ -48,6 +47,31 @@ def __init__(self):
self.data_sysfs_obj = {}
self.sysfs_obj = {}

# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')

proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")

return (platform, hwsku)

###################################################################################################################
# GENERIC DEFS
###################################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

try:
from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase
import time
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

try:
from sonic_platform_base.thermal_base import ThermalBase
import time
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import subprocess
import time
import unicodedata
from sonic_py_common import device_info

bmc_cache = {}
cache = {}
Expand All @@ -32,7 +31,7 @@
class PddfApi():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
self.platform, self.hwsku = device_info.get_platform_and_hwsku()
self.platform, self.hwsku = self.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+self.platform, "/usr/share/sonic/platform")

try:
Expand All @@ -45,6 +44,29 @@ def __init__(self):
self.data_sysfs_obj = {}
self.sysfs_obj = {}

# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')

proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")

return (platform, hwsku)

#################################################################################################################
# GENERIC DEFS
#################################################################################################################
Expand Down

0 comments on commit b725940

Please sign in to comment.