~zulcss/nova/nova-precise-g3

« back to all changes in this revision

Viewing changes to bin/nova-spicehtml5proxy

  • Committer: Chuck Short
  • Date: 2013-02-25 12:48:57 UTC
  • mfrom: (94.1.5 raring-proposed)
  • Revision ID: zulcss@ubuntu.com-20130225124857-iiz7w0zqhjo1sbs3
* New upstream release for the Ubuntu Cloud Archive. 
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.
* debian/control: Fix typo (websocikfy -> websockify).
* SECURITY UPDATE: fix lack of authentication on block device used for
  os-volume_boot
  - debian/patches/CVE-2013-0208.patch: adjust nova/compute/api.py to
    validate we can access the volumes
  - CVE-2013-0208

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
3
 
 
4
# Copyright (c) 2012 OpenStack, LLC.
 
5
# All Rights Reserved.
 
6
#
 
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
 
10
#
 
11
#         http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
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
 
17
#    under the License.
 
18
 
 
19
"""
 
20
Websocket proxy that is compatible with OpenStack Nova
 
21
SPICE HTML5 consoles. Leverages websockify.py by Joel Martin
 
22
"""
 
23
 
 
24
import os
 
25
import sys
 
26
 
 
27
from oslo.config import cfg
 
28
 
 
29
from nova import config
 
30
from nova.console import websocketproxy
 
31
 
 
32
 
 
33
opts = [
 
34
    cfg.BoolOpt('record',
 
35
                default=False,
 
36
                help='Record sessions to FILE.[session_number]'),
 
37
    cfg.BoolOpt('daemon',
 
38
                default=False,
 
39
                help='Become a daemon (background process)'),
 
40
    cfg.BoolOpt('ssl_only',
 
41
                default=False,
 
42
                help='Disallow non-encrypted connections'),
 
43
    cfg.BoolOpt('source_is_ipv6',
 
44
                default=False,
 
45
                help='Source is ipv6'),
 
46
    cfg.StrOpt('cert',
 
47
               default='self.pem',
 
48
               help='SSL certificate file'),
 
49
    cfg.StrOpt('key',
 
50
               default=None,
 
51
               help='SSL key file (if separate from cert)'),
 
52
    cfg.StrOpt('web',
 
53
               default='/usr/share/spice-html5',
 
54
               help='Run webserver on same port. Serve files from DIR.'),
 
55
    cfg.StrOpt('spicehtml5proxy_host',
 
56
               default='0.0.0.0',
 
57
               help='Host on which to listen for incoming requests'),
 
58
    cfg.IntOpt('spicehtml5proxy_port',
 
59
               default=6082,
 
60
               help='Port on which to listen for incoming requests'),
 
61
    ]
 
62
 
 
63
CONF = cfg.CONF
 
64
CONF.register_cli_opts(opts)
 
65
CONF.import_opt('debug', 'nova.openstack.common.log')
 
66
 
 
67
 
 
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)
 
71
 
 
72
    # Setup flags
 
73
    config.parse_args(sys.argv)
 
74
 
 
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
 
78
        sys.exit(-1)
 
79
 
 
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,
 
85
                                   verbose=CONF.verbose,
 
86
                                   cert=CONF.cert,
 
87
                                   key=CONF.key,
 
88
                                   ssl_only=CONF.ssl_only,
 
89
                                   daemon=CONF.daemon,
 
90
                                   record=CONF.record,
 
91
                                   web=CONF.web,
 
92
                                   target_host='ignore',
 
93
                                   target_port='ignore',
 
94
                                   wrap_mode='exit',
 
95
                                   wrap_cmd=None)
 
96
    server.start_server()