mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Config option to disable built-in templates
This commit is contained in:
parent
2eb64200a4
commit
67bf14776f
@ -59,6 +59,9 @@ allowed_interfaces = eth0,eth1,virbr0
|
||||
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
|
||||
default_nat_interface = vmnet10
|
||||
|
||||
; Enable the built-in templates
|
||||
enable_builtin_templates = True
|
||||
|
||||
[VPCS]
|
||||
; VPCS executable location, default: search in PATH
|
||||
;vpcs_path = vpcs
|
||||
|
@ -21,6 +21,7 @@ import aiohttp
|
||||
import jsonschema
|
||||
|
||||
from .template import Template
|
||||
from gns3server.config import Config
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@ -60,6 +61,7 @@ class TemplateManager:
|
||||
|
||||
# Add builtins
|
||||
builtins = []
|
||||
if Config.instance().get_section_config("Server").getboolean("enable_builtin_templates", True):
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "cloud"), {"template_type": "cloud", "name": "Cloud", "default_name_format": "Cloud{0}", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "nat"), {"template_type": "nat", "name": "NAT", "default_name_format": "NAT{0}", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "vpcs"), {"template_type": "vpcs", "name": "VPCS", "default_name_format": "PC{0}", "category": 2, "symbol": ":/symbols/vpcs_guest.svg", "properties": {"base_script_file": "vpcs_base_config.txt"}}, builtin=True))
|
||||
|
@ -24,6 +24,7 @@ import aiohttp
|
||||
from unittest.mock import MagicMock, patch
|
||||
from tests.utils import AsyncioMagicMock, asyncio_patch
|
||||
|
||||
from gns3server.config import Config
|
||||
from gns3server.controller.compute import Compute
|
||||
from gns3server.version import __version__
|
||||
|
||||
@ -451,6 +452,15 @@ def test_load_templates(controller):
|
||||
assert cloud_uuid == template.id
|
||||
|
||||
|
||||
def test_load_templates_without_builtins(controller):
|
||||
|
||||
config = Config.instance()
|
||||
config.set("Server", "enable_builtin_templates", False)
|
||||
controller.template_manager.load_templates()
|
||||
|
||||
assert not controller.template_manager.templates.values()
|
||||
|
||||
|
||||
async def test_autoidlepc(controller):
|
||||
|
||||
controller._computes["local"] = AsyncioMagicMock()
|
||||
|
Loading…
Reference in New Issue
Block a user