Platform ident should use onie-sysinfo

This commit is contained in:
Carl D. Roth
2017-12-26 17:48:08 -08:00
parent 1fdf13b506
commit 7550367afb

View File

@@ -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)