'Get text console output.'

@wsgi.Controller.api_version('2.1', '2.5')
@extensions.expected_errors((400, 404, 409, 501))
@wsgi.action('os-getRDPConsole')
@validation.schema(remote_consoles.get_rdp_console)
def get_rdp_console(self, req, id, body):

    context = req.environ['nova.context']
    context.can(rc_policies.BASE_POLICY_NAME)
    console_type = body['os-getRDPConsole'].get('type')
    instance = common.get_instance(self.compute_api, context, id)
    try:
        output = self.compute_api.get_rdp_console(context, instance, console_type)
    except exception.ConsoleTypeUnavailable as e:
        raise webob.exc.HTTPBadRequest(explanation=e.format_message())
    except (exception.InstanceUnknownCell, exception.InstanceNotFound) as e:
        raise webob.exc.HTTPNotFound(explanation=e.format_message())
    except exception.InstanceNotReady as e:
        raise webob.exc.HTTPConflict(explanation=e.format_message())
    except NotImplementedError:
        common.raise_feature_not_supported()
    return {'console': {'type': console_type, 'url': output['url']}}
