feat: add hdds/temps/version to display

* Write a mock ustorage tool to parse disk info for ulcmd
* Pass system temp info from unvr-fan-daemon to mock-ubnt-api via tmp file
* add mock ubnt-tools to make ulcmd happy and report our SN
* code cleanup and documentation update
This commit is contained in:
Chris Blake 2024-05-26 14:58:01 -05:00
parent a4f7f862c2
commit 9c08f287fc
7 changed files with 268 additions and 58 deletions

View file

@ -1,16 +1,39 @@
#!/usr/bin/python3
import os
from flask import Flask, jsonify
from functools import lru_cache
import socket
def __get_system_temp():
try:
with open("/tmp/.unvr_temp", "r") as f:
return float(f.read())
except (IOError, OSError, PermissionError) as e:
print(f"Warning: Unable to get device temp!")
return None
@lru_cache(None)
def __get_omv_version():
return os.popen("dpkg-query -W -f='${Version}' openmediavault").read()
app = Flask(__name__)
@app.route("/api/info")
def api_info():
print(socket.gethostname())
payload = {
"isSetup": True,
"hostname": socket.gethostname(),
"hardware": {
"firmwareVersion": f"OMV {__get_omv_version()}", # OMV version
},
"cpu": {
"temperature": __get_system_temp(),
},
}
return jsonify(payload)
@ -18,7 +41,7 @@ def api_info():
# No controllers for you
@app.route("/api/controllers")
def api_controllers():
return jsonify({})
return jsonify([])
if __name__ == "__main__":