netbox-agent/netbox_agent/misc.py
ThomasADavis b7b22ae316 use lshw for inventory (#58)
* Use lshw for inventory
* Add motherboard to inventory
* Handle non raid devices
* Handle nvme drives
2019-09-05 15:13:36 +02:00

28 lines
647 B
Python

from shutil import which
def is_tool(name):
'''Check whether `name` is on PATH and marked as executable.'''
return which(name) is not None
def get_vendor(name):
vendors = {
'ST': 'Seagate',
'CRUCIAL': 'Crucial',
'MICRON': 'Micron',
'INTEL': 'Intel',
'SAMSUNG': 'Samsung',
'EH0': 'HP',
'HGST': 'HGST',
'HUH': 'HGST',
'MB': 'Toshiba',
'MC': 'Toshiba',
'MD': 'Toshiba',
'MG': 'Toshiba',
'WD': 'WDC'
}
for key, value in vendors.items():
if name.upper().startswith(key):
return value
return name