mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Merge pull request #2073 from GNS3/disable-builtin-templates
Config setting to disable builtin templates
This commit is contained in:
commit
4acc457674
@ -59,6 +59,9 @@ allowed_interfaces = eth0,eth1,virbr0
|
|||||||
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
|
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
|
||||||
default_nat_interface = vmnet10
|
default_nat_interface = vmnet10
|
||||||
|
|
||||||
|
; Enable the built-in templates
|
||||||
|
enable_builtin_templates = True
|
||||||
|
|
||||||
[VPCS]
|
[VPCS]
|
||||||
; VPCS executable location, default: search in PATH
|
; VPCS executable location, default: search in PATH
|
||||||
;vpcs_path = vpcs
|
;vpcs_path = vpcs
|
||||||
|
@ -21,6 +21,7 @@ import aiohttp
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
from .template import Template
|
from .template import Template
|
||||||
|
from gns3server.config import Config
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -60,6 +61,7 @@ class TemplateManager:
|
|||||||
|
|
||||||
# Add builtins
|
# Add builtins
|
||||||
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, "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, "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))
|
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 unittest.mock import MagicMock, patch
|
||||||
from tests.utils import AsyncioMagicMock, asyncio_patch
|
from tests.utils import AsyncioMagicMock, asyncio_patch
|
||||||
|
|
||||||
|
from gns3server.config import Config
|
||||||
from gns3server.controller.compute import Compute
|
from gns3server.controller.compute import Compute
|
||||||
from gns3server.version import __version__
|
from gns3server.version import __version__
|
||||||
|
|
||||||
@ -451,6 +452,15 @@ def test_load_templates(controller):
|
|||||||
assert cloud_uuid == template.id
|
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):
|
async def test_autoidlepc(controller):
|
||||||
|
|
||||||
controller._computes["local"] = AsyncioMagicMock()
|
controller._computes["local"] = AsyncioMagicMock()
|
||||||
|
Loading…
Reference in New Issue
Block a user