diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py index bdf4c915..36e9e457 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py @@ -14,8 +14,9 @@ # platform-config packages. # ############################################################ -import os +import os, sys import importlib +import subprocess def platform_name_get(): # Determine the current platform name. @@ -23,6 +24,22 @@ def platform_name_get(): if os.path.exists("/etc/onl/platform"): with open("/etc/onl/platform", 'r') as f: platform=f.read().strip() + elif os.path.exists("/bin/onie-sysinfo"): + try: + platform = subprocess.check_output(('/bin/onie-sysinfo', '-p',)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo failed with code %d\n" % what.returncode) + platform = None + elif os.path.exists("/usr/bin/onie-shell"): + try: + platform = subprocess.check_output(('/usr/bin/onie-shell', '-c', "onie-sysinfo -p",)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo (onie-shell) failed with code %d\n" % what.returncode) + platform = None elif os.path.exists("/etc/machine.conf"): with open("/etc/machine.conf", 'r') as f: lines = f.readlines(False)