mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
Merge pull request #890 from GNS3/base_config_server_side
Manage base configuration on server
This commit is contained in:
commit
5672b4b748
31 files changed
+649
-324
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import os
|
||||
import json
|
||||
import socket
|
||||
import shutil
|
||||
import asyncio
|
||||
import aiohttp
|
||||
|
||||
@@ -29,7 +30,7 @@ from .symbols import Symbols
|
||||
from ..version import __version__
|
||||
from .topology import load_topology
|
||||
from .gns3vm import GNS3VM
|
||||
|
||||
from ..utils.get_resource import get_resource
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -53,6 +54,7 @@ class Controller:
|
||||
@asyncio.coroutine
|
||||
def start(self):
|
||||
log.info("Start controller")
|
||||
self.load_base_files()
|
||||
yield from self.load()
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
host = server_config.get("host", "localhost")
|
||||
@@ -162,6 +164,20 @@ class Controller:
|
||||
except OSError as e:
|
||||
log.error(str(e))
|
||||
|
||||
def load_base_files(self):
|
||||
"""
|
||||
At startup we copy base file to the user location to allow
|
||||
them to customize it
|
||||
"""
|
||||
dst_path = self.configs_path()
|
||||
src_path = get_resource('configs')
|
||||
try:
|
||||
for file in os.listdir(src_path):
|
||||
if not os.path.exists(os.path.join(dst_path, file)):
|
||||
shutil.copy(os.path.join(src_path, file), os.path.join(dst_path, file))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def images_path(self):
|
||||
"""
|
||||
Get the image storage directory
|
||||
@@ -171,6 +187,15 @@ class Controller:
|
||||
os.makedirs(images_path, exist_ok=True)
|
||||
return images_path
|
||||
|
||||
def configs_path(self):
|
||||
"""
|
||||
Get the configs storage directory
|
||||
"""
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
images_path = os.path.expanduser(server_config.get("configs_path", "~/GNS3/projects"))
|
||||
os.makedirs(images_path, exist_ok=True)
|
||||
return images_path
|
||||
|
||||
@asyncio.coroutine
|
||||
def _import_gns3_gui_conf(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user