mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Fix to access resources_path and install_builtin_appliances settings
This commit is contained in:
parent
59ad5c55ec
commit
3f7f5a3cda
@ -96,9 +96,12 @@ class Docker(BaseManager):
|
||||
Get the Docker resources storage directory
|
||||
"""
|
||||
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
resources_path = Config.instance().settings.Server.resources_path
|
||||
if not resources_path:
|
||||
appname = vendor = "GNS3"
|
||||
resources_path = os.path.expanduser(server_config.get("resources_path", platformdirs.user_data_dir(appname, vendor, roaming=True)))
|
||||
resources_path = platformdirs.user_data_dir(appname, vendor, roaming=True)
|
||||
else:
|
||||
resources_path = os.path.expanduser(resources_path)
|
||||
docker_resources_dir = os.path.join(resources_path, "docker")
|
||||
os.makedirs(docker_resources_dir, exist_ok=True)
|
||||
return docker_resources_dir
|
||||
|
@ -52,6 +52,11 @@ symbols_path = /home/gns3/GNS3/symbols
|
||||
; Path where custom configs are stored
|
||||
configs_path = /home/gns3/GNS3/configs
|
||||
|
||||
; 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
|
||||
|
||||
; Default symbol theme
|
||||
; Currently available themes are "Classic", Affinity-square-blue", "Affinity-square-red"
|
||||
; "Affinity-square-gray", "Affinity-circle-blue", "Affinity-circle-red" and "Affinity-circle-gray"
|
||||
@ -63,11 +68,6 @@ allow_raw_images = True
|
||||
; Option to automatically discover images in the images directory
|
||||
auto_discover_images = True
|
||||
|
||||
; 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
|
||||
report_errors = True
|
||||
|
||||
|
@ -271,9 +271,7 @@ class Controller:
|
||||
self._iou_license_settings["license_check"] = iou_config.license_check
|
||||
|
||||
# install the built-in appliances if needed
|
||||
# FIXME
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
if server_config.getboolean("install_builtin_appliances", True):
|
||||
if Config.instance().settings.Server.install_builtin_appliances:
|
||||
previous_version = controller_vars.get("version")
|
||||
log.info("Comparing controller version {} with config version {}".format(__version__, previous_version))
|
||||
builtin_appliances_path = self._appliance_manager.builtin_appliances_path()
|
||||
|
@ -100,9 +100,12 @@ class ApplianceManager:
|
||||
Get the built-in appliance storage directory
|
||||
"""
|
||||
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
resources_path = Config.instance().settings.Server.resources_path
|
||||
if not resources_path:
|
||||
appname = vendor = "GNS3"
|
||||
resources_path = os.path.expanduser(server_config.get("resources_path", platformdirs.user_data_dir(appname, vendor, roaming=True)))
|
||||
resources_path = platformdirs.user_data_dir(appname, vendor, roaming=True)
|
||||
else:
|
||||
resources_path = os.path.expanduser(resources_path)
|
||||
appliances_dir = os.path.join(resources_path, "appliances")
|
||||
if delete_first:
|
||||
shutil.rmtree(appliances_dir, ignore_errors=True)
|
||||
|
@ -127,6 +127,7 @@ class ServerSettings(BaseModel):
|
||||
appliances_path: str = "~/GNS3/appliances"
|
||||
symbols_path: str = "~/GNS3/symbols"
|
||||
configs_path: str = "~/GNS3/configs"
|
||||
resources_path: str = None
|
||||
default_symbol_theme: BuiltinSymbolTheme = BuiltinSymbolTheme.affinity_square_blue
|
||||
allow_raw_images: bool = True
|
||||
auto_discover_images: bool = True
|
||||
@ -145,6 +146,7 @@ class ServerSettings(BaseModel):
|
||||
default_nat_interface: str = None
|
||||
allow_remote_console: bool = False
|
||||
enable_builtin_templates: bool = True
|
||||
install_builtin_appliances: bool = True
|
||||
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True, use_enum_values=True)
|
||||
|
||||
@field_validator("additional_images_paths", mode="before")
|
||||
|
Loading…
Reference in New Issue
Block a user