summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/test_virt_drivers.py9
-rw-r--r--nova/virt/driver.py4
-rw-r--r--nova/virt/fake.py6
-rw-r--r--nova/virt/libvirt/driver.py21
4 files changed, 40 insertions, 0 deletions
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index 199ae30b1..9747ecccd 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -446,6 +446,15 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
self.assertIn('port', vnc_console)
@catch_notimplementederror
+ def test_get_spice_console(self):
+ instance_ref, network_info = self._get_running_instance()
+ spice_console = self.connection.get_spice_console(instance_ref)
+ self.assertIn('internal_access_path', spice_console)
+ self.assertIn('host', spice_console)
+ self.assertIn('port', spice_console)
+ self.assertIn('tlsPort', spice_console)
+
+ @catch_notimplementederror
def test_get_console_pool_info(self):
instance_ref, network_info = self._get_running_instance()
console_pool = self.connection.get_console_pool_info(instance_ref)
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index a8f779e66..aa0439e74 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -258,6 +258,10 @@ class ComputeDriver(object):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
+ def get_spice_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 0a29a6d67..338d1dec1 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -271,6 +271,12 @@ class FakeDriver(driver.ComputeDriver):
'host': 'fakevncconsole.com',
'port': 6969}
+ def get_spice_console(self, instance):
+ return {'internal_access_path': 'FAKE',
+ 'host': 'fakespiceconsole.com',
+ 'port': 6969,
+ 'tlsPort': 6970}
+
def get_console_pool_info(self, console_type):
return {'address': '127.0.0.1',
'username': 'fakeuser',
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 557818a99..a10dc6f2f 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -1146,6 +1146,27 @@ class LibvirtDriver(driver.ComputeDriver):
return {'host': host, 'port': port, 'internal_access_path': None}
+ @exception.wrap_exception()
+ def get_spice_console(self, instance):
+ def get_spice_ports_for_instance(instance_name):
+ virt_dom = self._lookup_by_name(instance_name)
+ xml = virt_dom.XMLDesc(0)
+ # TODO(sleepsonthefloor): use etree instead of minidom
+ dom = minidom.parseString(xml)
+
+ for graphic in dom.getElementsByTagName('graphics'):
+ if graphic.getAttribute('type') == 'spice':
+ return (graphic.getAttribute('port'),
+ graphic.getAttribute('tlsPort'))
+
+ return (None, None)
+
+ ports = get_spice_ports_for_instance(instance['name'])
+ host = CONF.spice.server_proxyclient_address
+
+ return {'host': host, 'port': ports[0],
+ 'tlsPort': ports[1], 'internal_access_path': None}
+
@staticmethod
def _supports_direct_io(dirpath):