mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-26 17:57:01 +00:00
Platform ident should use onie-sysinfo
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user