88cf6458d0
Application web d'inventaire réseau manuel avec FastAPI, Vue 3 et Docker. Inclut l'authentification JWT, la découverte ICMP, et la topologie en cards CSS. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String, unique=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
must_change_password = Column(Boolean, nullable=False, default=False, server_default="0")
|
|
token_version = Column(Integer, nullable=False, default=1, server_default="1")
|
|
|
|
|
|
class Vlan(Base):
|
|
__tablename__ = "vlans"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
vlan_id = Column(Integer, unique=True, nullable=True)
|
|
name = Column(String, nullable=False)
|
|
cidr = Column(String, nullable=True, default="")
|
|
color = Column(String, default="#4A90D9")
|
|
|
|
interfaces = relationship("DeviceInterface", back_populates="vlan")
|
|
|
|
|
|
class Device(Base):
|
|
__tablename__ = "devices"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
type = Column(String, default="other")
|
|
description = Column(String, default="")
|
|
is_gateway = Column(Boolean, default=False)
|
|
is_livebox = Column(Boolean, default=False)
|
|
virt_type = Column(String, nullable=True)
|
|
url = Column(String, nullable=True)
|
|
|
|
interfaces = relationship(
|
|
"DeviceInterface", back_populates="device", cascade="all, delete-orphan"
|
|
)
|
|
|
|
|
|
class DeviceInterface(Base):
|
|
__tablename__ = "device_interfaces"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False)
|
|
vlan_id = Column(Integer, ForeignKey("vlans.id"), nullable=True)
|
|
ip_address = Column(String, nullable=True, default="")
|
|
name = Column(String, default="eth0")
|
|
is_upstream = Column(Boolean, default=False)
|
|
|
|
device = relationship("Device", back_populates="interfaces")
|
|
vlan = relationship("Vlan", back_populates="interfaces")
|
|
|
|
|