Files
Agentic-OS/backend/app/models/inventory.py
nearxos 6185b9b85a Initial commit: Agentic OS troubleshooting platform
Self-hosted, Docker-based agentic troubleshooting platform: FastAPI backend +
LangGraph agent, Next.js UI, tiered LLM routing (local Ollama -> Gemini ->
DeepSeek -> OpenRouter), MCP server manager, encrypted device credentials,
RBAC, audit log, project-memory + Obsidian integrations, and editable
troubleshooting decision rules tuned for the GeneseasX vessel stack.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 22:11:07 +03:00

49 lines
2.1 KiB
Python

"""Vessels and their onboard devices (inventory with encrypted credentials)."""
from __future__ import annotations
from datetime import datetime
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.database import Base
from app.models.enums import DeviceType
class Vessel(Base):
__tablename__ = "vessels"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(255), index=True)
site: Mapped[str | None] = mapped_column(String(255), nullable=True)
# Public IP / endpoint used to reach devices on this vessel (port forwards)
public_ip: Mapped[str | None] = mapped_column(String(255), nullable=True)
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
devices: Mapped[list["Device"]] = relationship(
back_populates="vessel", cascade="all, delete-orphan"
)
class Device(Base):
__tablename__ = "devices"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(255), index=True)
# Catalog slot key (e.g. proxmox, pfsense, docker_vm)
catalog_key: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
device_type: Mapped[DeviceType] = mapped_column(Enum(DeviceType), default=DeviceType.other)
address: Mapped[str] = mapped_column(String(255))
port: Mapped[int | None] = mapped_column(Integer, nullable=True)
mcp_server: Mapped[str | None] = mapped_column(String(128), nullable=True)
username: Mapped[str | None] = mapped_column(String(255), nullable=True)
secret_enc: Mapped[str | None] = mapped_column(Text, nullable=True)
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
vessel_id: Mapped[int | None] = mapped_column(
ForeignKey("vessels.id", ondelete="CASCADE"), nullable=True, index=True
)
vessel: Mapped[Vessel | None] = relationship(back_populates="devices")
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())