mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Merge pull request #5 from planctechnologies/gns3-87-bugfixes
Gns-87 bugfixes
This commit is contained in:
commit
800d4d91f9
@ -62,7 +62,7 @@ C=CA
|
|||||||
ST=Alberta
|
ST=Alberta
|
||||||
O=GNS3
|
O=GNS3
|
||||||
localityName=Calgary
|
localityName=Calgary
|
||||||
commonName=gns3server.localdomain.com
|
commonName=$DOMAIN
|
||||||
organizationalUnitName=GNS3Server
|
organizationalUnitName=GNS3Server
|
||||||
emailAddress=gns3cert@gns3.com
|
emailAddress=gns3cert@gns3.com
|
||||||
"
|
"
|
||||||
|
@ -29,6 +29,9 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class GNS3BaseHandler(tornado.web.RequestHandler):
|
class GNS3BaseHandler(tornado.web.RequestHandler):
|
||||||
def get_current_user(self):
|
def get_current_user(self):
|
||||||
|
if 'required_user' not in self.settings:
|
||||||
|
return "FakeUser"
|
||||||
|
|
||||||
user = self.get_secure_cookie("user")
|
user = self.get_secure_cookie("user")
|
||||||
if not user:
|
if not user:
|
||||||
return None
|
return None
|
||||||
@ -38,6 +41,9 @@ class GNS3BaseHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
class GNS3WebSocketBaseHandler(tornado.websocket.WebSocketHandler):
|
class GNS3WebSocketBaseHandler(tornado.websocket.WebSocketHandler):
|
||||||
def get_current_user(self):
|
def get_current_user(self):
|
||||||
|
if 'required_user' not in self.settings:
|
||||||
|
return "FakeUser"
|
||||||
|
|
||||||
user = self.get_secure_cookie("user")
|
user = self.get_secure_cookie("user")
|
||||||
if not user:
|
if not user:
|
||||||
return None
|
return None
|
||||||
|
@ -54,6 +54,16 @@ class DeadMan(IModule):
|
|||||||
if 'heartbeat_file' in kwargs:
|
if 'heartbeat_file' in kwargs:
|
||||||
self._heartbeat_file = kwargs['heartbeat_file']
|
self._heartbeat_file = kwargs['heartbeat_file']
|
||||||
|
|
||||||
|
self._is_enabled = False
|
||||||
|
try:
|
||||||
|
cloud_config = Config.instance().get_section_config("CLOUD_SERVER")
|
||||||
|
instance_id = cloud_config["instance_id"]
|
||||||
|
cloud_user_name = cloud_config["cloud_user_name"]
|
||||||
|
cloud_api_key = cloud_config["cloud_api_key"]
|
||||||
|
self._is_enabled = True
|
||||||
|
except KeyError:
|
||||||
|
log.critical("Missing cloud.conf - disabling Deadman Switch")
|
||||||
|
|
||||||
self._deadman_process = None
|
self._deadman_process = None
|
||||||
self.heartbeat()
|
self.heartbeat()
|
||||||
self.start()
|
self.start()
|
||||||
@ -73,7 +83,7 @@ class DeadMan(IModule):
|
|||||||
cmd.append("--file")
|
cmd.append("--file")
|
||||||
cmd.append("%s" % (self._heartbeat_file))
|
cmd.append("%s" % (self._heartbeat_file))
|
||||||
cmd.append("--background")
|
cmd.append("--background")
|
||||||
log.debug("Deadman: Running %s"%(cmd))
|
log.debug("Deadman: Running command: %s"%(cmd))
|
||||||
|
|
||||||
process = subprocess.Popen(cmd, stderr=subprocess.STDOUT, shell=False)
|
process = subprocess.Popen(cmd, stderr=subprocess.STDOUT, shell=False)
|
||||||
return process
|
return process
|
||||||
@ -87,7 +97,7 @@ class DeadMan(IModule):
|
|||||||
|
|
||||||
cmd.append("gns3dms")
|
cmd.append("gns3dms")
|
||||||
cmd.append("-k")
|
cmd.append("-k")
|
||||||
log.debug("Deadman: Running %s"%(cmd))
|
log.debug("Deadman: Running command: %s"%(cmd))
|
||||||
|
|
||||||
process = subprocess.Popen(cmd, shell=False)
|
process = subprocess.Popen(cmd, shell=False)
|
||||||
return process
|
return process
|
||||||
@ -116,6 +126,7 @@ class DeadMan(IModule):
|
|||||||
Start the deadman process on the server
|
Start the deadman process on the server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self._is_enabled:
|
||||||
self._deadman_process = self._start_deadman_process()
|
self._deadman_process = self._start_deadman_process()
|
||||||
log.debug("Deadman: Process is starting")
|
log.debug("Deadman: Process is starting")
|
||||||
|
|
||||||
|
@ -146,17 +146,37 @@ class Server(object):
|
|||||||
Starts the Tornado web server and ZeroMQ server.
|
Starts the Tornado web server and ZeroMQ server.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# FIXME: debug mode!
|
|
||||||
cloud_config = Config.instance().get_section_config("CLOUD_SERVER")
|
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
"debug":True,
|
"debug":True,
|
||||||
"cookie_secret": base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
|
"cookie_secret": base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
|
||||||
"login_url": "/login",
|
"login_url": "/login",
|
||||||
|
}
|
||||||
|
|
||||||
|
ssl_options = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
cloud_config = Config.instance().get_section_config("CLOUD_SERVER")
|
||||||
|
|
||||||
|
cloud_settings = {
|
||||||
|
|
||||||
"required_user" : cloud_config['WEB_USERNAME'],
|
"required_user" : cloud_config['WEB_USERNAME'],
|
||||||
"required_pass" : cloud_config['WEB_PASSWORD'],
|
"required_pass" : cloud_config['WEB_PASSWORD'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.update(cloud_settings)
|
||||||
|
|
||||||
|
if cloud_config["SSL_ENABLED"] == "yes":
|
||||||
|
ssl_options = {
|
||||||
|
"certfile" : cloud_config["SSL_CRT"],
|
||||||
|
"keyfile" : cloud_config["SSL_KEY"],
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Certs found - starting in SSL mode")
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
log.info("Missing cloud.conf - disabling HTTP auth and SSL")
|
||||||
|
|
||||||
|
|
||||||
router = self._create_zmq_router()
|
router = self._create_zmq_router()
|
||||||
# Add our JSON-RPC Websocket handler to Tornado
|
# Add our JSON-RPC Websocket handler to Tornado
|
||||||
self.handlers.extend([(r"/", JSONRPCWebSocket, dict(zmq_router=router))])
|
self.handlers.extend([(r"/", JSONRPCWebSocket, dict(zmq_router=router))])
|
||||||
@ -176,13 +196,7 @@ class Server(object):
|
|||||||
zmq.zmq_version()))
|
zmq.zmq_version()))
|
||||||
kwargs = {"address": self._host}
|
kwargs = {"address": self._host}
|
||||||
|
|
||||||
if cloud_config["SSL_ENABLED"] == "yes":
|
if ssl_options:
|
||||||
ssl_options = {
|
|
||||||
"certfile" : cloud_config["SSL_CRT"],
|
|
||||||
"keyfile" : cloud_config["SSL_KEY"],
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Certs found - starting in SSL mode")
|
|
||||||
kwargs["ssl_options"] = ssl_options
|
kwargs["ssl_options"] = ssl_options
|
||||||
|
|
||||||
if parse_version(tornado.version) >= parse_version("3.1"):
|
if parse_version(tornado.version) >= parse_version("3.1"):
|
||||||
|
Loading…
Reference in New Issue
Block a user