Skip to content

Commit

Permalink
ns-api: fix hardware info for ARM boards (#873)
Browse files Browse the repository at this point in the history
On ARM boards, some devices are not present
  • Loading branch information
gsanchietti authored Oct 28, 2024
1 parent b5a2469 commit 5a80430
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/ns-api/files/ns.dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ def get_version():
return ret

def get_hardware():
try:
with open('/sys/devices/virtual/dmi/id/board_name') as f:
return f.read().lstrip().rstrip()
except:
with open('/sys/devices/virtual/dmi/id/product_name') as f:
# read info for x86_64
if os.path.isdir('/sys/devices/virtual/dmi/id'):
if os.path.exists('/sys/devices/virtual/dmi/id/board_name'):
with open('/sys/devices/virtual/dmi/id/board_name') as f:
return f.read().lstrip().rstrip()
if os.path.exists('/sys/devices/virtual/dmi/id/product_name'):
with open('/sys/devices/virtual/dmi/id/product_name') as f:
return f.read().lstrip().rstrip()
# read info for arm
if os.path.exists('/sys/firmware/devicetree/base/model'):
with open('/sys/firmware/devicetree/base/model') as f:
return f.read().lstrip().rstrip()
return "Unknown"

def _run(cmd):
try:
Expand Down

0 comments on commit 5a80430

Please sign in to comment.