This repository has been archived on 2025-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
Files
salt-master/_grains/hardware.py

28 lines
867 B
Python

#!/usr/bin/env python3
import re
import os.path
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" and os.path.isfile("/etc/armbian-release"):
for line in open("/etc/armbian-release","r").readlines():
if re.match("BOARD=espressobin", line):
h = "Espressobin"
if re.match("BOARD=pine64", line):
h = "Pine64"
return h
def main():
grains = {}
grains['hardware'] = _hardware()
return grains