Fix config option to disable built-in templates.

This commit is contained in:
grossmj committed 2022-06-21 17:17:44 +02:00
1 parent d8b928f1c1
commit 410f062721
3 files changed
+18 -2

No files matched your search

+1
View File
@@ -138,6 +138,7 @@ class ServerSettings(BaseModel):
allowed_interfaces: List[str] = Field(default_factory=list)
default_nat_interface: str = None
allow_remote_console: bool = False
enable_builtin_templates: bool = True
@validator("additional_images_paths", pre=True)
def split_additional_images_paths(cls, v):
+4 -2
View File
@@ -23,6 +23,7 @@ from fastapi.encoders import jsonable_encoder
from typing import List
from gns3server import schemas
from gns3server.config import Config
import gns3server.db.models as models
from gns3server.db.repositories.templates import TemplatesRepository
from gns3server.controller.controller_error import (
@@ -174,8 +175,9 @@ class TemplatesService:
db_templates = await self._templates_repo.get_templates()
for db_template in db_templates:
templates.append(db_template.asjson())
for builtin_template in BUILTIN_TEMPLATES:
templates.append(jsonable_encoder(builtin_template))
if Config.instance().settings.Server.enable_builtin_templates:
for builtin_template in BUILTIN_TEMPLATES:
templates.append(jsonable_encoder(builtin_template))
return templates
async def _find_image(self, image_path: str):