summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2011-12-22 21:39:21 +0000
committerAnthony Young <sleepsonthefloor@gmail.com>2012-01-17 14:18:31 -0800
commit8d010cacb520786fa12794801bc31eddd23b2af7 (patch)
tree51609a7c80b6a62128a9819fadb0064209e17a81 /nova/virt
parent5987ed97ffb90e52acb7a7d9e0a915d072aadaed (diff)
Implements blueprint vnc-console-cleanup
* Creates a unified way to access vnc consoles for xenserver and libvirt * Now supports both java and websocket clients * Removes nova-vncproxy - a replacement version of this (nova-novncproxy) can be found as described in vncconsole.rst * Adds nova-xvpvncproxy, which supports a java vnc client * Adds api extension to access java and novnc access_urls * Fixes proxy server to close/shutdown sockets more cleanly * Address style feedback * Use new-style extension format * Fix setup.py * utils.gen_uuid must be wrapped like str(utils.gen_uuid()) or it can't be serialized Change-Id: I5e42e2f160e8e3476269bd64b0e8aa77e66c918c
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/driver.py4
-rw-r--r--nova/virt/fake.py2
-rw-r--r--nova/virt/libvirt/connection.py3
-rw-r--r--nova/virt/xenapi/vmops.py14
-rw-r--r--nova/virt/xenapi_conn.py9
5 files changed, 29 insertions, 3 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index e03793561..7a9347542 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -195,6 +195,10 @@ class ComputeDriver(object):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
+ def get_vnc_console(self, instance):
+ # TODO(Vek): Need to pass context in for access to auth_token
+ raise NotImplementedError()
+
def get_diagnostics(self, instance):
"""Return data about VM diagnostics"""
# TODO(Vek): Need to pass context in for access to auth_token
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 3311834c2..f8f535eb4 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -225,7 +225,7 @@ class FakeConnection(driver.ComputeDriver):
'port': 6969}
def get_vnc_console(self, instance):
- return {'token': 'FAKETOKEN',
+ return {'internal_access_path': 'FAKE',
'host': 'fakevncconsole.com',
'port': 6969}
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 85c48e495..4e5c86ea4 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -781,10 +781,9 @@ class LibvirtConnection(driver.ComputeDriver):
return graphic.getAttribute('port')
port = get_vnc_port_for_instance(instance['name'])
- token = str(uuid.uuid4())
host = instance['host']
- return {'token': token, 'host': host, 'port': port}
+ return {'host': host, 'port': port, 'internal_access_path': None}
@staticmethod
def _cache_image(fn, target, fname, cow=False, *args, **kwargs):
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 99f5ca650..e92581213 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -59,6 +59,9 @@ flags.DEFINE_integer('xenapi_running_timeout', 60,
flags.DEFINE_string('xenapi_vif_driver',
'nova.virt.xenapi.vif.XenAPIBridgeDriver',
'The XenAPI VIF driver using XenServer Network APIs.')
+flags.DEFINE_string('dom0_address',
+ '169.254.0.1',
+ 'Ip address of dom0. Override for multi-host vnc.')
flags.DEFINE_bool('xenapi_generate_swap',
False,
'Whether to generate swap (False means fetching it'
@@ -1381,6 +1384,17 @@ class VMOps(object):
# TODO: implement this!
return 'http://fakeajaxconsole/fake_url'
+ def get_vnc_console(self, instance):
+ """Return connection info for a vnc console."""
+ vm_ref = self._get_vm_opaque_ref(instance)
+ session_id = self._session.get_session_id()
+ path = "/console?ref=%s&session_id=%s"\
+ % (str(vm_ref), session_id)
+
+ # NOTE: XS5.6sp2+ use http over port 80 for xenapi com
+ return {'host': FLAGS.dom0_address, 'port': 80,
+ 'internal_access_path': path}
+
def host_power_action(self, host, action):
"""Reboots or shuts down the host."""
args = {"action": json.dumps(action)}
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index e672a3cb5..bfce96423 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -338,6 +338,10 @@ class XenAPIConnection(driver.ComputeDriver):
"""Return link to instance's ajax console"""
return self._vmops.get_ajax_console(instance)
+ def get_vnc_console(self, instance):
+ """Return link to instance's ajax console"""
+ return self._vmops.get_vnc_console(instance)
+
@staticmethod
def get_host_ip_addr():
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
@@ -493,6 +497,11 @@ class XenAPISession(object):
"""Stubout point. This can be replaced with a mock xenapi module."""
return __import__('XenAPI')
+ def get_session_id(self):
+ """Return a string session_id. Used for vnc consoles."""
+ with self._get_session() as session:
+ return str(session._session)
+
@contextlib.contextmanager
def _get_session(self):
"""Return exclusive session for scope of with statement"""