diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2012-12-18 12:41:21 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2013-01-16 10:19:37 +0000 |
commit | d597993a07eff1b8b88b11e7dc44edaf177067b8 (patch) | |
tree | cf733614bdfa3ce02849a14cb6c9094cbdd0f2a1 | |
parent | eab051ec68bdc8792dddb63c9231ece11ab06037 (diff) | |
download | nova-d597993a07eff1b8b88b11e7dc44edaf177067b8.tar.gz nova-d597993a07eff1b8b88b11e7dc44edaf177067b8.tar.xz nova-d597993a07eff1b8b88b11e7dc44edaf177067b8.zip |
Add a get_spice_console method to nova.virt.ComputeDriver API
To mirror the existing get_vnc_console method, add a new
get_spice_console method to nova.virt.ComputeDriver API.
No attempt is made to wire this up to the RPC API, since at
this time there is no equivalent of novnc or xvpvncproxy to
use with SPICE.
Blueprint: libvirt-spice
Change-Id: I4cf12074b240d6882e46a81783cf20a3d97d4b2a
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
-rw-r--r-- | nova/tests/test_virt_drivers.py | 9 | ||||
-rw-r--r-- | nova/virt/driver.py | 4 | ||||
-rw-r--r-- | nova/virt/fake.py | 6 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 21 |
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): |