2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
4
# Copyright (c) 2012 OpenStack, LLC.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
20
Websocket proxy that is compatible with OpenStack Nova
21
SPICE HTML5 consoles. Leverages websockify.py by Joel Martin
27
from oslo.config import cfg
29
from nova import config
30
from nova.console import websocketproxy
36
help='Record sessions to FILE.[session_number]'),
39
help='Become a daemon (background process)'),
40
cfg.BoolOpt('ssl_only',
42
help='Disallow non-encrypted connections'),
43
cfg.BoolOpt('source_is_ipv6',
45
help='Source is ipv6'),
48
help='SSL certificate file'),
51
help='SSL key file (if separate from cert)'),
53
default='/usr/share/spice-html5',
54
help='Run webserver on same port. Serve files from DIR.'),
55
cfg.StrOpt('spicehtml5proxy_host',
57
help='Host on which to listen for incoming requests'),
58
cfg.IntOpt('spicehtml5proxy_port',
60
help='Port on which to listen for incoming requests'),
64
CONF.register_cli_opts(opts)
65
CONF.import_opt('debug', 'nova.openstack.common.log')
68
if __name__ == '__main__':
69
if CONF.ssl_only and not os.path.exists(CONF.cert):
70
parser.error("SSL only and %s not found" % CONF.cert)
73
config.parse_args(sys.argv)
75
# Check to see if spice html/js/css files are present
76
if not os.path.exists(CONF.web):
77
print "Can not find spice html/js/css files at %s." % CONF.web
80
# Create and start the NovaWebSockets proxy
81
server = websocketproxy.NovaWebSocketProxy(
82
listen_host=CONF.spicehtml5proxy_host,
83
listen_port=CONF.spicehtml5proxy_port,
84
source_is_ipv6=CONF.source_is_ipv6,
88
ssl_only=CONF.ssl_only,