mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 08:44:52 +02:00
Add 'install_builtin_appliances' and 'resources_path' settings in the server config
This commit is contained in:
parent
90dce03da2
commit
ca1d99b112
@ -9,18 +9,23 @@ ssl = False
|
|||||||
certfile=/home/gns3/.config/GNS3/ssl/server.cert
|
certfile=/home/gns3/.config/GNS3/ssl/server.cert
|
||||||
certkey=/home/gns3/.config/GNS3/ssl/server.key
|
certkey=/home/gns3/.config/GNS3/ssl/server.key
|
||||||
|
|
||||||
; Path where devices images are stored
|
; Path where binary images are stored
|
||||||
images_path = /home/gns3/GNS3/images
|
images_path = /home/gns3/GNS3/images
|
||||||
|
|
||||||
; Path where user projects are stored
|
; Path where user projects are stored
|
||||||
projects_path = /home/gns3/GNS3/projects
|
projects_path = /home/gns3/GNS3/projects
|
||||||
|
|
||||||
; Path where user appliances are stored
|
; Path where custom user appliances are stored
|
||||||
appliances_path = /home/gns3/GNS3/appliances
|
appliances_path = /home/gns3/GNS3/appliances
|
||||||
|
|
||||||
; Path where custom device symbols are stored
|
; Path where custom user symbols are stored
|
||||||
symbols_path = /home/gns3/GNS3/symbols
|
symbols_path = /home/gns3/GNS3/symbols
|
||||||
|
|
||||||
|
; Path where files like built-in appliances and Docker resources are stored
|
||||||
|
; The default path is the local user data directory
|
||||||
|
; (Linux: "~/.local/share/GNS3", macOS: "~/Library/Application Support/GNS3", Windows: "%APPDATA%\GNS3")
|
||||||
|
; resources_path = /home/gns3/GNS3/resources
|
||||||
|
|
||||||
; Option to automatically send crash reports to the GNS3 team
|
; Option to automatically send crash reports to the GNS3 team
|
||||||
report_errors = True
|
report_errors = True
|
||||||
|
|
||||||
@ -62,6 +67,9 @@ default_nat_interface = vmnet10
|
|||||||
; Enable the built-in templates
|
; Enable the built-in templates
|
||||||
enable_builtin_templates = True
|
enable_builtin_templates = True
|
||||||
|
|
||||||
|
; Install built-in appliances
|
||||||
|
install_builtin_appliances = True
|
||||||
|
|
||||||
; check if hardware virtualization is used by other emulators (KVM, VMware or VirtualBox)
|
; check if hardware virtualization is used by other emulators (KVM, VMware or VirtualBox)
|
||||||
hardware_virtualization_check = True
|
hardware_virtualization_check = True
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import shutil
|
|||||||
import platformdirs
|
import platformdirs
|
||||||
|
|
||||||
from gns3server.utils import parse_version
|
from gns3server.utils import parse_version
|
||||||
|
from gns3server.config import Config
|
||||||
from gns3server.utils.asyncio import locking
|
from gns3server.utils.asyncio import locking
|
||||||
from gns3server.compute.base_manager import BaseManager
|
from gns3server.compute.base_manager import BaseManager
|
||||||
from gns3server.compute.docker.docker_vm import DockerVM
|
from gns3server.compute.docker.docker_vm import DockerVM
|
||||||
@ -96,8 +97,10 @@ class Docker(BaseManager):
|
|||||||
Get the Docker resources storage directory
|
Get the Docker resources storage directory
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
server_config = Config.instance().get_section_config("Server")
|
||||||
appname = vendor = "GNS3"
|
appname = vendor = "GNS3"
|
||||||
docker_resources_dir = os.path.join(platformdirs.user_data_dir(appname, vendor, roaming=True), "docker", "resources")
|
resources_path = os.path.expanduser(server_config.get("resources_path", platformdirs.user_data_dir(appname, vendor, roaming=True)))
|
||||||
|
docker_resources_dir = os.path.join(resources_path, "docker")
|
||||||
os.makedirs(docker_resources_dir, exist_ok=True)
|
os.makedirs(docker_resources_dir, exist_ok=True)
|
||||||
return docker_resources_dir
|
return docker_resources_dir
|
||||||
|
|
||||||
|
@ -248,13 +248,19 @@ class Controller:
|
|||||||
if "iou_license" in controller_settings:
|
if "iou_license" in controller_settings:
|
||||||
self._iou_license_settings = controller_settings["iou_license"]
|
self._iou_license_settings = controller_settings["iou_license"]
|
||||||
|
|
||||||
|
# install the built-in appliances if needed
|
||||||
|
server_config = Config.instance().get_section_config("Server")
|
||||||
|
if server_config.getboolean("install_builtin_appliances", True):
|
||||||
previous_version = controller_settings.get("version")
|
previous_version = controller_settings.get("version")
|
||||||
log.info("Comparing controller version {} with config version {}".format(__version__, previous_version))
|
log.info("Comparing controller version {} with config version {}".format(__version__, previous_version))
|
||||||
|
builtin_appliances_path = self._appliance_manager.builtin_appliances_path()
|
||||||
if not previous_version or \
|
if not previous_version or \
|
||||||
parse_version(__version__.split("+")[0]) > parse_version(previous_version.split("+")[0]):
|
parse_version(__version__.split("+")[0]) > parse_version(previous_version.split("+")[0]):
|
||||||
self._appliance_manager.install_builtin_appliances()
|
self._appliance_manager.install_builtin_appliances()
|
||||||
elif not os.listdir(self._appliance_manager.builtin_appliances_path()):
|
elif not os.listdir(builtin_appliances_path):
|
||||||
self._appliance_manager.install_builtin_appliances()
|
self._appliance_manager.install_builtin_appliances()
|
||||||
|
else:
|
||||||
|
log.info("Built-in appliances are installed in '{}'".format(builtin_appliances_path))
|
||||||
|
|
||||||
self._appliance_manager.appliances_etag = controller_settings.get("appliances_etag")
|
self._appliance_manager.appliances_etag = controller_settings.get("appliances_etag")
|
||||||
self._appliance_manager.load_appliances()
|
self._appliance_manager.load_appliances()
|
||||||
|
@ -87,8 +87,10 @@ class ApplianceManager:
|
|||||||
Get the built-in appliance storage directory
|
Get the built-in appliance storage directory
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
server_config = Config.instance().get_section_config("Server")
|
||||||
appname = vendor = "GNS3"
|
appname = vendor = "GNS3"
|
||||||
appliances_dir = os.path.join(platformdirs.user_data_dir(appname, vendor, roaming=True), "appliances")
|
resources_path = os.path.expanduser(server_config.get("resources_path", platformdirs.user_data_dir(appname, vendor, roaming=True)))
|
||||||
|
appliances_dir = os.path.join(resources_path, "appliances")
|
||||||
if delete_first:
|
if delete_first:
|
||||||
shutil.rmtree(appliances_dir, ignore_errors=True)
|
shutil.rmtree(appliances_dir, ignore_errors=True)
|
||||||
os.makedirs(appliances_dir, exist_ok=True)
|
os.makedirs(appliances_dir, exist_ok=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user