summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2011-03-23 17:23:04 -0700
committerAnthony Young <sleepsonthefloor@gmail.com>2011-03-23 17:23:04 -0700
commit61b52830cdce9ac5ec75d744f07764e535bcae35 (patch)
treeef57d0b805be6fa91522f863988ea420f911da56 /bin
parent6912b0e1efd6ba3814d3b29beef236bfe4da52ea (diff)
parent85ad729e4448bb4211b79e325cef897fc4e2b0bb (diff)
Merge branch 'vnc_console' of git://github.com/sleepsonthefloor/nova into vnc_console
Conflicts: nova/virt/libvirt_conn.py
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-vnc-proxy94
1 files changed, 94 insertions, 0 deletions
diff --git a/bin/nova-vnc-proxy b/bin/nova-vnc-proxy
new file mode 100755
index 000000000..ea2533dc3
--- /dev/null
+++ b/bin/nova-vnc-proxy
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# pylint: disable-msg=C0103
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""VNC Console Proxy Server"""
+
+import eventlet
+import gettext
+import os
+import sys
+
+possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+ os.pardir,
+ os.pardir))
+if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
+ sys.path.insert(0, possible_topdir)
+
+gettext.install('nova', unicode=1)
+
+from nova import flags
+from nova import log as logging
+from nova import utils
+from nova import wsgi
+from nova import version
+from nova.vnc import auth
+from nova.vnc import proxy
+
+LOG = logging.getLogger('nova.vnc-proxy')
+
+FLAGS = flags.FLAGS
+flags.DEFINE_string('vnc_proxy_wwwroot', '/var/lib/nova/noVNC/',
+ 'Full path to noVNC directory')
+flags.DEFINE_boolean('vnc_debug', False,
+ 'Enable debugging features, like token bypassing')
+flags.DEFINE_integer('vnc_proxy_port', 6080,
+ 'Port that the VNC proxy should bind to')
+flags.DEFINE_string('vnc_proxy_iface', '0.0.0.0',
+ 'Address that the VNC proxy should bind to')
+flags.DEFINE_integer('vnc_token_ttl', 300,
+ 'How many seconds before deleting tokens')
+flags.DEFINE_flag(flags.HelpFlag())
+flags.DEFINE_flag(flags.HelpshortFlag())
+flags.DEFINE_flag(flags.HelpXMLFlag())
+
+if __name__ == "__main__":
+ utils.default_flagfile()
+ FLAGS(sys.argv)
+ logging.setup()
+
+ LOG.audit(_("Starting nova-vnc-proxy node (version %s)"),
+ version.version_string_with_vcs())
+
+ if not (os.path.exists(FLAGS.vnc_proxy_wwwroot) and
+ os.path.exists(FLAGS.vnc_proxy_wwwroot + '/vnc_auto.html')):
+ LOG.info(_("Missing vnc_proxy_wwwroot (version %s)"),
+ FLAGS.vnc_proxy_wwwroot)
+ LOG.info(_("You need a slightly modified version of noVNC "
+ "to work with the nova-vnc-proxy"))
+ LOG.info(_("Check out the most recent nova noVNC code: %s"),
+ "git://github.com/sleepsonthefloor/noVNC.git")
+ LOG.info(_("And drop it in %s"), FLAGS.vnc_proxy_wwwroot)
+ exit(1)
+
+ app = proxy.WebsocketVNCProxy(FLAGS.vnc_proxy_wwwroot)
+
+ LOG.audit(_("Allowing access to the following files: %s"),
+ app.get_whitelist())
+
+ with_logging = auth.LoggingMiddleware(app)
+
+ if FLAGS.vnc_debug:
+ with_auth = proxy.DebugMiddleware(with_logging)
+ else:
+ with_auth = auth.NovaAuthMiddleware(with_logging)
+
+ server = wsgi.Server()
+ server.start(with_auth, FLAGS.vnc_proxy_port, host=FLAGS.vnc_proxy_iface)
+ server.wait()