def get_console(request, console_type, instance):
 if (console_type == 'AUTO'):
  check_consoles = CONSOLES
 else:
  try:
   check_consoles = {console_type: CONSOLES[console_type]}
  except KeyError:
   msg = (_('Console type "%s" not supported.') % console_type)
   raise exceptions.NotAvailable(msg)
 try:
  httpnotimplemented = nova_exception.HttpNotImplemented
 except AttributeError:
  httpnotimplemented = nova_exception.HTTPNotImplemented
 for (con_type, api_call) in check_consoles.items():
  try:
   console = api_call(request, instance.id)
  except httpnotimplemented:
   continue
  except Exception:
   LOG.debug('Console not available', exc_info=True)
   continue
  if (con_type == 'SERIAL'):
   console_url = console.url
  else:
   console_url = ('%s&%s(%s)' % (console.url, urlencode({'title': getattr(instance, 'name', '')}), instance.id))
  return (con_type, console_url)
 raise exceptions.NotAvailable(_('No available console found.'))

def get_console ( request , console_type , instance ) : if ( console_type == 'AUTO' ) : check_consoles = CONSOLES else : try : check_consoles = { console_type : CONSOLES [ console_type ] } except KeyError : msg = ( _ ( 'Console type "%s" not supported.' ) % console_type ) raise exceptions . NotAvailable ( msg ) try : httpnotimplemented = nova_exception . HttpNotImplemented except AttributeError : httpnotimplemented = nova_exception . HTTPNotImplemented for ( con_type , api_call ) in check_consoles . items ( ) : try : console = api_call ( request , instance . id ) except httpnotimplemented : continue except Exception : LOG . debug ( 'Console not available' , exc_info = True ) continue if ( con_type == 'SERIAL' ) : console_url = console . url else : console_url = ( '%s&%s(%s)' % ( console . url , urlencode ( { 'title' : getattr ( instance , 'name' , '' ) } ) , instance . id ) ) return ( con_type , console_url ) raise exceptions . NotAvailable ( _ ( 'No available console found.' ) )
get a tuple of console url and console type .