Skip to content

Instantly share code, notes, and snippets.

@DirectXMan12
Created February 18, 2014 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DirectXMan12/9080857 to your computer and use it in GitHub Desktop.
Save DirectXMan12/9080857 to your computer and use it in GitHub Desktop.
Updating Nova WebsocketProxy to use Websockify v0.6.0
diff --git a/nova/cmd/novncproxy.py b/nova/cmd/novncproxy.py
index 6d30822..0ce9c47 100644
--- a/nova/cmd/novncproxy.py
+++ b/nova/cmd/novncproxy.py
@@ -24,11 +24,11 @@ import os
import sys
from oslo.config import cfg
+import websockify
from nova import config
from nova.console import websocketproxy
-
opts = [
cfg.StrOpt('novncproxy_host',
default='0.0.0.0',
@@ -64,21 +64,24 @@ def main():
return(-1)
# Create and start the NovaWebSockets proxy
- server = websocketproxy.NovaWebSocketProxy(
- listen_host=CONF.novncproxy_host,
- listen_port=CONF.novncproxy_port,
- source_is_ipv6=CONF.source_is_ipv6,
- verbose=CONF.verbose,
- cert=CONF.cert,
- key=CONF.key,
- ssl_only=CONF.ssl_only,
- daemon=CONF.daemon,
- record=CONF.record,
- web=CONF.web,
- file_only=True,
- no_parent=True,
- target_host='ignore',
- target_port='ignore',
- wrap_mode='exit',
- wrap_cmd=None)
+ server = websockify.WebSocketProxy(
+ listen_host=CONF.novncproxy_host,
+ listen_port=CONF.novncproxy_port,
+ source_is_ipv6=CONF.source_is_ipv6,
+ verbose=CONF.verbose,
+ cert=CONF.cert,
+ key=CONF.key,
+ ssl_only=CONF.ssl_only,
+ daemon=CONF.daemon,
+ record=CONF.record,
+ web=CONF.web,
+ file_only=True,
+ target_host='ignore',
+ target_port='ignore',
+ wrap_mode='exit',
+ wrap_cmd=None,
+ unix_target=None,
+ ssl_target=None,
+ target_cfg=None,
+ RequestHandlerClass=websocketproxy.NovaProxyRequestHandler)
server.start_server()
diff --git a/nova/console/websocketproxy.py b/nova/console/websocketproxy.py
index d2bb555..aeedead 100644
--- a/nova/console/websocketproxy.py
+++ b/nova/console/websocketproxy.py
@@ -31,13 +31,8 @@ from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
-class NovaWebSocketProxy(websockify.WebSocketProxy):
- def __init__(self, *args, **kwargs):
- websockify.WebSocketProxy.__init__(self, unix_target=None,
- target_cfg=None,
- ssl_target=None, *args, **kwargs)
-
- def new_client(self):
+class NovaProxyRequestHandler(websockify.ProxyRequestHandler):
+ def new_websocket_client(self):
"""
Called after a new WebSocket connection has been established.
"""
@@ -63,7 +58,7 @@ class NovaWebSocketProxy(websockify.WebSocketProxy):
# Connect to the target
self.msg("connecting to: %s:%s" % (host, port))
LOG.audit("connecting to: %s:%s" % (host, port))
- tsock = self.socket(host, port, connect=True)
+ tsock = websockify.WebSocketServer.socket(host, port, connect=True)
# Handshake as necessary
if connect_info.get('internal_access_path'):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment