From 593350c3a78b8ceb6e9b8017e687a5cd93b76132 Mon Sep 17 00:00:00 2001 From: host Date: Sun, 9 Aug 2026 16:43:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20LXC-=D1=88=D0=B0=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BD=D0=BE=D0=B2=20=D0=BF=D0=BE=20CTID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/schemas.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/app/schemas.py b/backend/app/schemas.py index 11ba706..4fbc003 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -41,11 +41,13 @@ class TemplateCreate(BaseModel): @model_validator(mode="after") def validate_source(self): - """Проверяет источник в зависимости от типа гостя.""" + """Для VM и LXC требует один из допустимых источников.""" if self.guest_type == GuestType.vm and self.source_vmid is None: raise ValueError("Для VM требуется source_vmid") - if self.guest_type == GuestType.lxc and not self.source_template: - raise ValueError("Для LXC требуется source_template") + if self.guest_type == GuestType.lxc and self.source_vmid is None and not self.source_template: + raise ValueError("Для LXC требуется source_vmid или source_template") + if self.source_vmid is not None and self.source_template is not None: + raise ValueError("Нельзя одновременно указывать source_vmid и source_template") return self