diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-01-17 11:59:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-17 11:59:39 +0000 |
commit | 9ae14c7570bb9dfc4bf1ab8f8127cae3c9eb2641 (patch) | |
tree | c6275c5327499cec9434bce301967f1f30ea33fa | |
parent | b76c5cfc8eca20ee55d3f47b103140d1cbd372cd (diff) | |
parent | d597993a07eff1b8b88b11e7dc44edaf177067b8 (diff) | |
download | nova-9ae14c7570bb9dfc4bf1ab8f8127cae3c9eb2641.tar.gz nova-9ae14c7570bb9dfc4bf1ab8f8127cae3c9eb2641.tar.xz nova-9ae14c7570bb9dfc4bf1ab8f8127cae3c9eb2641.zip |
Merge "Add a get_spice_console method to nova.virt.ComputeDriver API"
-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): |