def get_spice_console(self, context, instance):

    def get_spice_ports_for_instance(instance_name):
        virt_dom = self._lookup_by_name(instance_name)
        xml = virt_dom.XMLDesc(0)
        dom = xmlutils.safe_minidom_parse_string(xml)
        for graphic in dom.getElementsByTagName('graphics'):
            if (graphic.getAttribute('type') == 'spice'):
                return (graphic.getAttribute('port'), graphic.getAttribute('tlsPort'))
        raise exception.ConsoleTypeUnavailable(console_type='spice')
    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}
def get_spice_console(self, context, instance):

    def get_spice_ports_for_instance(instance_name):
        virt_dom = self._lookup_by_name(instance_name)
        xml = virt_dom.XMLDesc(0)
        dom = xmlutils.safe_minidom_parse_string(xml)
        for graphic in dom.getElementsByTagName('graphics'):
            if (graphic.getAttribute('type') == 'spice'):
                return (graphic.getAttribute('port'), graphic.getAttribute('tlsPort'))
        raise exception.ConsoleTypeUnavailable(console_type='spice')
    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}