Merge "Add a get_spice_console method to nova.virt.ComputeDriver API"
This commit is contained in:
		@@ -445,6 +445,15 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
 | 
			
		||||
        self.assertIn('host', vnc_console)
 | 
			
		||||
        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()
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user