2013-10-30 21:58:17 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2013 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import sys
|
2014-03-16 03:41:04 +00:00
|
|
|
import multiprocessing
|
2013-10-30 21:58:17 +00:00
|
|
|
import logging
|
|
|
|
import tornado.options
|
2013-12-22 00:34:51 +00:00
|
|
|
import gns3server
|
2013-10-30 21:58:17 +00:00
|
|
|
|
|
|
|
# command line options
|
|
|
|
from tornado.options import define
|
2014-01-31 23:31:34 +00:00
|
|
|
define("host", default="0.0.0.0", help="run on the given host/IP address", type=str)
|
2013-10-30 21:58:17 +00:00
|
|
|
define("port", default=8000, help="run on the given port", type=int)
|
2013-12-05 07:21:06 +00:00
|
|
|
define("ipc", default=False, help="use IPC for module communication", type=bool)
|
2013-10-30 21:58:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2013-12-05 07:21:06 +00:00
|
|
|
"""
|
|
|
|
Entry point for GNS3 server
|
|
|
|
"""
|
2013-10-30 21:58:17 +00:00
|
|
|
|
2014-03-16 03:41:04 +00:00
|
|
|
if sys.platform.startswith("win"):
|
|
|
|
# necessary on Windows to use freezing software
|
|
|
|
multiprocessing.freeze_support()
|
|
|
|
|
2013-10-30 21:58:17 +00:00
|
|
|
current_year = datetime.date.today().year
|
|
|
|
print("GNS3 server version {}".format(gns3server.__version__))
|
|
|
|
print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year))
|
|
|
|
|
|
|
|
# we only support Python 2 version >= 2.7 and Python 3 version >= 3.3
|
|
|
|
if sys.version_info < (2, 7):
|
|
|
|
raise RuntimeError("Python 2.7 or higher is required")
|
|
|
|
elif sys.version_info[0] == 3 and sys.version_info < (3, 3):
|
|
|
|
raise RuntimeError("Python 3.3 or higher is required")
|
|
|
|
|
|
|
|
try:
|
|
|
|
tornado.options.parse_command_line()
|
|
|
|
except (tornado.options.Error, ValueError):
|
|
|
|
tornado.options.print_help()
|
|
|
|
raise SystemExit
|
|
|
|
|
2013-12-05 07:21:06 +00:00
|
|
|
# FIXME: log everything for now (excepting DEBUG)
|
2013-10-30 21:58:17 +00:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
2013-12-05 07:21:06 +00:00
|
|
|
from tornado.options import options
|
|
|
|
server = gns3server.Server(options.host,
|
|
|
|
options.port,
|
|
|
|
ipc=options.ipc)
|
|
|
|
server.load_modules()
|
2013-10-30 21:58:17 +00:00
|
|
|
server.run()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|