summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2011-03-24 15:55:29 -0700
committerAnthony Young <sleepsonthefloor@gmail.com>2011-03-24 15:55:29 -0700
commitb01742ddb5bfec7e89ccc4cee17800614a0fce3c (patch)
tree14650b80a6d2669b9a2aa9c8babc5fa7d28097cf /nova
parent71bd388a6c04df68e4392dbb7354cc8b14f596fe (diff)
incorporate feedback from termie
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/api.py15
-rw-r--r--nova/compute/manager.py2
-rw-r--r--nova/flags.py4
-rw-r--r--nova/virt/libvirt.xml.template4
-rw-r--r--nova/virt/libvirt_conn.py3
-rw-r--r--nova/vnc/auth.py22
-rw-r--r--nova/vnc/proxy.py15
7 files changed, 34 insertions, 31 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index cec978d75..cb3898f72 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -477,21 +477,22 @@ class API(base.Base):
output['token'])}
def get_vnc_console(self, context, instance_id):
- """Get a url to an AJAX Console"""
+ """Get a url to a VNC Console."""
instance = self.get(context, instance_id)
output = self._call_compute_message('get_vnc_console',
context,
instance_id)
rpc.cast(context, '%s' % FLAGS.vnc_console_proxy_topic,
{'method': 'authorize_vnc_console',
- 'args': {'token': output['token'], 'host': output['host'],
+ 'args': {'token': output['token'],
+ 'host': output['host'],
'port': output['port']}})
- time.sleep(1)
-
- return {'url': '%s/vnc_auto.html?token=%s&host=%s&port=%s' %
- (FLAGS.vnc_console_proxy_url,
- output['token'], 'hostignore', 'portignore')}
+ return {'url': '%s/vnc_auto.html?token=%s&host=%s&port=%s' % (
+ FLAGS.vnc_console_proxy_url,
+ output['token'],
+ 'hostignore',
+ 'portignore')}
def get_console_output(self, context, instance_id):
"""Get console output for an an instance"""
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e53b36b34..64982d8ff 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -559,7 +559,7 @@ class ComputeManager(manager.Manager):
@exception.wrap_exception
def get_vnc_console(self, context, instance_id):
- """Return connection information for an vnc console"""
+ """Return connection information for an vnc console."""
context = context.elevated()
LOG.debug(_("instance %s: getting vnc console"), instance_id)
instance_ref = self.db.instance_get(context, instance_id)
diff --git a/nova/flags.py b/nova/flags.py
index a0ea10795..1d2469206 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -287,8 +287,8 @@ DEFINE_string('vnc_console_proxy_url',
'http://127.0.0.1:6080',
'location of vnc console proxy, \
in the form "http://127.0.0.1:6080"')
-DEFINE_string('vnc_compute_host_iface', '0.0.0.0',
- 'the compute host interface on which vnc server should listen')
+DEFINE_string('vnc_server_host', '0.0.0.0',
+ 'the host interface on which vnc server should listen')
DEFINE_bool('vnc_enabled', True,
'enable vnc related features')
DEFINE_bool('verbose', False, 'show debug output')
diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template
index ff98275fc..609784982 100644
--- a/nova/virt/libvirt.xml.template
+++ b/nova/virt/libvirt.xml.template
@@ -101,8 +101,8 @@
<target port='0'/>
</serial>
-#if $getVar('vnc_compute_host_iface', False)
- <graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='${vnc_compute_host_iface}'/>
+#if $getVar('vnc_server_host', False)
+ <graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='${vnc_server_host}'/>
#end if
</devices>
</domain>
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index c3529f512..cb6384e01 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -516,6 +516,7 @@ class LibvirtConnection(object):
def get_vnc_port_for_instance(instance_name):
virt_dom = self._conn.lookupByName(instance_name)
xml = virt_dom.XMLDesc(0)
+ # TODO: use etree instead of minidom
dom = minidom.parseString(xml)
for graphic in dom.getElementsByTagName('graphics'):
@@ -735,7 +736,7 @@ class LibvirtConnection(object):
'driver_type': driver_type}
if FLAGS.vnc_enabled:
- xml_info['vnc_compute_host_iface'] = FLAGS.vnc_compute_host_iface
+ xml_info['vnc_server_host'] = FLAGS.vnc_server_host
if ra_server:
xml_info['ra_server'] = ra_server + "/128"
if not rescue:
diff --git a/nova/vnc/auth.py b/nova/vnc/auth.py
index 676cb2360..1c6a638fc 100644
--- a/nova/vnc/auth.py
+++ b/nova/vnc/auth.py
@@ -18,11 +18,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Auth Components for VNC Console"""
+"""Auth Components for VNC Console."""
import time
import urlparse
import webob
+
from webob import Request
from nova import flags
@@ -32,12 +33,13 @@ from nova import utils
from nova import wsgi
from nova import vnc
+
LOG = logging.getLogger('nova.vnc-proxy')
FLAGS = flags.FLAGS
class NovaAuthMiddleware(object):
- """Implementation of Middleware to Handle Nova Auth"""
+ """Implementation of Middleware to Handle Nova Auth."""
def __init__(self, app):
self.app = app
@@ -67,13 +69,12 @@ class NovaAuthMiddleware(object):
middleware = self
middleware.tokens = {}
- class Callback:
- def __call__(self, data, message):
- if data['method'] == 'authorize_vnc_console':
- token = data['args']['token']
- LOG.audit(_("Received Token: %s)"), token)
- middleware.tokens[token] = \
- {'args': data['args'], 'last_activity_at': time.time()}
+ def callback(self, data, message):
+ if data['method'] == 'authorize_vnc_console':
+ token = data['args']['token']
+ LOG.audit(_("Received Token: %s)"), token)
+ middleware.tokens[token] = \
+ {'args': data['args'], 'last_activity_at': time.time()}
def delete_expired_tokens():
now = time.time()
@@ -90,7 +91,7 @@ class NovaAuthMiddleware(object):
consumer = rpc.TopicConsumer(
connection=conn,
topic=FLAGS.vnc_console_proxy_topic)
- consumer.register_callback(Callback())
+ consumer.register_callback(callback)
utils.LoopingCall(consumer.fetch, auto_ack=True,
enable_callbacks=True).start(0.1)
@@ -103,7 +104,6 @@ class LoggingMiddleware(object):
@webob.dec.wsgify
def __call__(self, req):
-
if req.path == vnc.proxy.WS_ENDPOINT:
LOG.info(_("Received Websocket Request: %s"), req.url)
else:
diff --git a/nova/vnc/proxy.py b/nova/vnc/proxy.py
index dea838e3d..49379d9ae 100644
--- a/nova/vnc/proxy.py
+++ b/nova/vnc/proxy.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# pylint: disable-msg=C0103
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
@@ -20,11 +19,13 @@
"""Eventlet WSGI Services to proxy VNC. No nova deps."""
-from base64 import b64encode, b64decode
+import base64
+import os
+
import eventlet
from eventlet import wsgi
from eventlet import websocket
-import os
+
from webob import Request
import webob
@@ -32,7 +33,7 @@ WS_ENDPOINT = '/data'
class WebsocketVNCProxy(object):
- """Class to proxy from websocket to vnc server"""
+ """Class to proxy from websocket to vnc server."""
def __init__(self, wwwroot):
self.wwwroot = wwwroot
@@ -58,7 +59,7 @@ class WebsocketVNCProxy(object):
d = source.recv(32384)
if d == '':
break
- d = b64encode(d)
+ d = base64.b64encode(d)
dest.send(d)
except:
source.close()
@@ -70,7 +71,7 @@ class WebsocketVNCProxy(object):
d = source.wait()
if d is None:
break
- d = b64decode(d)
+ d = base64.b64decode(d)
dest.sendall(d)
except:
source.close()
@@ -118,7 +119,7 @@ class WebsocketVNCProxy(object):
class DebugMiddleware(object):
- """Debug middleware. Skip auth, get vnc port and host from query string"""
+ """Debug middleware. Skip auth, get vnc connect info from query string."""
def __init__(self, app):
self.app = app