mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-20 05:17:56 +00:00
Flag --local
This commit is contained in:
parent
8e249b670d
commit
59f940625a
@ -20,10 +20,12 @@ import os
|
||||
import datetime
|
||||
import sys
|
||||
import locale
|
||||
import argparse
|
||||
|
||||
from gns3server.server import Server
|
||||
from gns3server.web.logger import init_logger
|
||||
from gns3server.version import __version__
|
||||
from gns3server.config import Config
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@ -68,6 +70,24 @@ def locale_check():
|
||||
log.info("current locale is {}.{}".format(language, encoding))
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
|
||||
parser = argparse.ArgumentParser(description='GNS 3 server')
|
||||
parser.add_argument('--local',
|
||||
action="store_true",
|
||||
dest='local',
|
||||
help='Local mode (allow some insecure operations)')
|
||||
args = parser.parse_args()
|
||||
|
||||
config = Config.instance()
|
||||
server_config = config.get_section_config("Server")
|
||||
|
||||
if args.local:
|
||||
server_config["local"] = "true"
|
||||
|
||||
config.set_section_config("Server", server_config)
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Entry point for GNS3 server
|
||||
@ -89,8 +109,15 @@ def main():
|
||||
user_log = init_logger(logging.DEBUG, quiet=False)
|
||||
# FIXME END Temporary
|
||||
|
||||
parse_arguments()
|
||||
|
||||
user_log.info("GNS3 server version {}".format(__version__))
|
||||
user_log.info("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year))
|
||||
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
if server_config["local"]:
|
||||
log.warning("Local mode is enabled. Beware it's allow a full control on your filesystem")
|
||||
|
||||
# TODO: end todo
|
||||
|
||||
# we only support Python 3 version >= 3.3
|
||||
|
@ -23,6 +23,10 @@ from uuid import UUID, uuid4
|
||||
from ..config import Config
|
||||
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Project:
|
||||
"""
|
||||
A project contains a list of VM.
|
||||
@ -60,6 +64,7 @@ class Project:
|
||||
os.makedirs(os.path.join(self._path, "vms"), exist_ok=True)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not create project directory: {}".format(e))
|
||||
log.debug("Create project {uuid} in directory {path}".format(path=self._path, uuid=self._uuid))
|
||||
|
||||
def _get_default_project_directory(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user