Initial release — Salus by Stranto v1.6.1.0
FastAPI/Jinja2 web app for viewing and rebooting TP-Link Omada APs across all sites. Authentik OIDC auth, SQLite audit log, Docker deploy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
36
app/database.py
Normal file
36
app/database.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import datetime
|
||||
from sqlalchemy import create_engine, Column, Integer, String, DateTime
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
|
||||
DATABASE_URL = f"sqlite:///{os.getenv('DB_PATH', '/data/audit.db')}"
|
||||
|
||||
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class RebootLog(Base):
|
||||
__tablename__ = "reboot_log"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
timestamp = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||
username = Column(String, nullable=False)
|
||||
user_email = Column(String, nullable=False)
|
||||
ap_name = Column(String, nullable=False)
|
||||
ap_mac = Column(String, nullable=False)
|
||||
ap_ip = Column(String, nullable=True)
|
||||
result = Column(String, nullable=False) # "success" | "error"
|
||||
error_message = Column(String, nullable=True)
|
||||
|
||||
|
||||
def init_db():
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user