'Return connection information for a RDP console.'

@messaging.expected_exceptions(exception.ConsoleTypeInvalid, exception.InstanceNotReady, exception.InstanceNotFound, exception.ConsoleTypeUnavailable, NotImplementedError)
@wrap_exception()
@wrap_instance_fault
def get_rdp_console(self, context, console_type, instance):

    context = context.elevated()
    LOG.debug('Getting    RDP    console', instance=instance)
    token = uuidutils.generate_uuid()
    if (not CONF.rdp.enabled):
        raise exception.ConsoleTypeUnavailable(console_type=console_type)
    if (console_type == 'rdp-html5'):
        access_url = ('%s?token=%s' % (CONF.rdp.html5_proxy_base_url, token))
    else:
        raise exception.ConsoleTypeInvalid(console_type=console_type)
    try:
        console = self.driver.get_rdp_console(context, instance)
        connect_info = console.get_connection_info(token, access_url)
    except exception.InstanceNotFound:
        if (instance.vm_state != vm_states.BUILDING):
            raise
        raise exception.InstanceNotReady(instance_id=instance.uuid)
    return connect_info
