hardware grain

This commit is contained in:
do
2020-06-06 22:10:03 +02:00
parent f9bc8015e0
commit 7b29bff448
2 changed files with 24 additions and 0 deletions

24
_grains/hardware.py Normal file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env python3
import re
def _hardware():
h = "unknown"
for line in open("/proc/cpuinfo","r").readlines():
if re.match("Hardware.*:.*Tegra", line):
h = "Tegra"
if re.match("Model.*:.*Raspberry", line):
h = "RaspberryPi"
if re.match("Hardware.*:.*sun50iw1p1", line):
h = "Pine64"
if re.match("Hardware\s+:\sFreescale\si.MX6\sQuad\/DualLite", line):
h = "RiotBoard"
if h == "unknown":
for line in open("/etc/armbian-release","r").readlines():
if re.match("BOARD=espressobin", line):
h = "Espressobin"
return h
def main():
grains = {}
grains['hardware'] = _hardware()
return grains