|
|
|
@ -78,38 +78,22 @@ def locale_check():
|
|
|
|
|
log.info("Current locale is {}.{}".format(language, encoding))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_arguments(argv, config):
|
|
|
|
|
def parse_arguments(argv):
|
|
|
|
|
"""
|
|
|
|
|
Parse command line arguments and override local configuration
|
|
|
|
|
|
|
|
|
|
:params args: Array of command line arguments
|
|
|
|
|
:params config: ConfigParser with default variable from configuration
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
defaults = {
|
|
|
|
|
"host": config.get("host", "0.0.0.0"),
|
|
|
|
|
"port": config.get("port", 8000),
|
|
|
|
|
"ssl": config.getboolean("ssl", False),
|
|
|
|
|
"certfile": config.get("certfile", ""),
|
|
|
|
|
"certkey": config.get("certkey", ""),
|
|
|
|
|
"record": config.get("record", ""),
|
|
|
|
|
"local": config.getboolean("local", False),
|
|
|
|
|
"allow": config.getboolean("allow_remote_console", False),
|
|
|
|
|
"quiet": config.getboolean("quiet", False),
|
|
|
|
|
"debug": config.getboolean("debug", False),
|
|
|
|
|
"live": config.getboolean("live", False),
|
|
|
|
|
"logfile": config.getboolean("logfile", ""),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="GNS3 server version {}".format(__version__))
|
|
|
|
|
parser.set_defaults(**defaults)
|
|
|
|
|
parser.add_argument("-v", "--version", help="show the version", action="version", version=__version__)
|
|
|
|
|
parser.add_argument("--host", help="run on the given host/IP address")
|
|
|
|
|
parser.add_argument("--port", help="run on the given port", type=int)
|
|
|
|
|
parser.add_argument("--ssl", action="store_true", help="run in SSL mode")
|
|
|
|
|
parser.add_argument("--config", help="Configuration file")
|
|
|
|
|
parser.add_argument("--certfile", help="SSL cert file")
|
|
|
|
|
parser.add_argument("--certkey", help="SSL key file")
|
|
|
|
|
parser.add_argument("--record", help="save curl requests into a file")
|
|
|
|
|
parser.add_argument("--record", help="save curl requests into a file (for developers)")
|
|
|
|
|
parser.add_argument("-L", "--local", action="store_true", help="local mode (allows some insecure operations)")
|
|
|
|
|
parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports")
|
|
|
|
|
parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout")
|
|
|
|
@ -120,6 +104,27 @@ def parse_arguments(argv, config):
|
|
|
|
|
parser.add_argument("--daemon", action="store_true", help="start as a daemon")
|
|
|
|
|
parser.add_argument("--pid", help="store process pid")
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
|
if args.config:
|
|
|
|
|
Config.instance(files=[args.config])
|
|
|
|
|
|
|
|
|
|
config = Config.instance().get_section_config("Server")
|
|
|
|
|
defaults = {
|
|
|
|
|
"host": config.get("host", "0.0.0.0"),
|
|
|
|
|
"port": config.get("port", 8000),
|
|
|
|
|
"ssl": config.getboolean("ssl", False),
|
|
|
|
|
"certfile": config.get("certfile", ""),
|
|
|
|
|
"certkey": config.get("certkey", ""),
|
|
|
|
|
"record": config.get("record", ""),
|
|
|
|
|
"local": config.getboolean("local", False),
|
|
|
|
|
"allow": config.getboolean("allow_remote_console", False),
|
|
|
|
|
"quiet": config.getboolean("quiet", False),
|
|
|
|
|
"debug": config.getboolean("debug", False),
|
|
|
|
|
"live": config.getboolean("live", False),
|
|
|
|
|
"logfile": config.getboolean("logfile", ""),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.set_defaults(**defaults)
|
|
|
|
|
return parser.parse_args(argv)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -173,7 +178,7 @@ def pid_lock(path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
|
|
|
|
args = parse_arguments(sys.argv[1:], Config.instance().get_section_config("Server"))
|
|
|
|
|
args = parse_arguments(sys.argv[1:])
|
|
|
|
|
|
|
|
|
|
if args.daemon and sys.platform.startswith("win"):
|
|
|
|
|
log.critical("Daemon is not supported on Windows")
|
|
|
|
|