feat: auto-detect OS from description; expand OS_LIST to 51 distros
- Remove os field from Device API and form — OS is now detected automatically from name/description via detectOs() in brandIcons.js - Expand OS_LIST from 20 to 51 entries covering all major distros (Debian/Ubuntu flavours, Red Hat, SUSE, Arch, BSD, security distros, Windows/macOS/iOS/Android, generic Linux/BSD catch-alls) - Display detected OS icon in IpAddressing.vue description column - Fix virt_type validator to normalise empty string to null Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -146,6 +146,19 @@ def _migrate_users():
|
||||
conn.commit()
|
||||
|
||||
|
||||
def _migrate_device_os():
|
||||
"""Ajoute la colonne os sur devices si absente."""
|
||||
with engine.connect() as conn:
|
||||
if not conn.execute(text(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='devices'"
|
||||
)).fetchone():
|
||||
return
|
||||
cols = [row[1] for row in conn.execute(text("PRAGMA table_info(devices)")).fetchall()]
|
||||
if 'os' not in cols:
|
||||
conn.execute(text("ALTER TABLE devices ADD COLUMN os VARCHAR"))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def _migrate_drop_links_table():
|
||||
"""Supprime la table links (fonctionnalité retirée en phase 3). Idempotent."""
|
||||
with engine.connect() as conn:
|
||||
@@ -162,6 +175,7 @@ def _migrate_drop_links_table():
|
||||
_migrate_vlan_nullable()
|
||||
_migrate_device_virt_type()
|
||||
_migrate_device_url()
|
||||
_migrate_device_os()
|
||||
_migrate_users_must_change_password()
|
||||
_migrate_users_token_version()
|
||||
_migrate_force_admin_password_change()
|
||||
|
||||
@@ -36,6 +36,7 @@ class Device(Base):
|
||||
is_livebox = Column(Boolean, default=False)
|
||||
virt_type = Column(String, nullable=True)
|
||||
url = Column(String, nullable=True)
|
||||
os = Column(String, nullable=True)
|
||||
|
||||
interfaces = relationship(
|
||||
"DeviceInterface", back_populates="device", cascade="all, delete-orphan"
|
||||
|
||||
@@ -91,6 +91,8 @@ class DeviceCreate(BaseModel):
|
||||
@field_validator("virt_type")
|
||||
@classmethod
|
||||
def _virt_type(cls, v: Optional[str]) -> Optional[str]:
|
||||
if not v:
|
||||
return None
|
||||
if v not in _VALID_VIRT_TYPES:
|
||||
raise ValueError(f"Invalid virt_type: {v!r}. Must be one of: baremetal, lxc, qemu")
|
||||
return v
|
||||
@@ -104,7 +106,6 @@ class DeviceCreate(BaseModel):
|
||||
raise ValueError("url must be a valid http or https URL")
|
||||
return v
|
||||
|
||||
|
||||
class DeviceOut(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user