'Get hypervisors for the given request.
:param req: nova.api.openstack.wsgi.Request for the GET request
:param detail: If True, return a detailed response.
:param limit: An optional user-supplied page limit.
:param marker: An optional user-supplied marker for paging.
:param links: If True, return links in the response for paging.'

def _get_hypervisors(self, req, detail=False, limit=None, marker=None, links=False):

    context = req.environ['nova.context']
    context.can(hv_policies.BASE_POLICY_NAME)
    if api_version_request.is_supported(req, min_version=UUID_FOR_ID_MIN_VERSION):
        hypervisor_match = req.GET.get('hypervisor_hostname_pattern')
        with_servers = strutils.bool_from_string(req.GET.get('with_servers', False), strict=True)
    else:
        hypervisor_match = None
        with_servers = False
    if (hypervisor_match is not None):
        if (('limit' in req.GET) or marker):
            raise webob.exc.HTTPBadRequest(_('Paging    over    hypervisors    with    the    hypervisor_hostname_pattern    query    parameter    is    not    supported.'))
        links = False
        compute_nodes = self._get_compute_nodes_by_name_pattern(context, hypervisor_match)
    else:
        try:
            compute_nodes = self.host_api.compute_node_get_all(context, limit=limit, marker=marker)
        except exception.MarkerNotFound:
            msg = (_('marker    [%s]    not    found') % marker)
            raise webob.exc.HTTPBadRequest(explanation=msg)
    hypervisors_list = []
    for hyp in compute_nodes:
        try:
            instances = None
            if with_servers:
                instances = self.host_api.instance_get_all_by_host(context, hyp.host)
            service = self.host_api.service_get_by_compute_host(context, hyp.host)
            hypervisors_list.append(self._view_hypervisor(hyp, service, detail, req, servers=instances))
        except (exception.ComputeHostNotFound, exception.HostMappingNotFound):
            LOG.debug('Unable    to    find    service    for    compute    node    %s.    The    service    may    be    deleted    and    compute    nodes    need    to    be    manually    cleaned    up.', hyp.host)
    hypervisors_dict = dict(hypervisors=hypervisors_list)
    if links:
        hypervisors_links = self._view_builder.get_links(req, hypervisors_list, detail)
        if hypervisors_links:
            hypervisors_dict['hypervisors_links'] = hypervisors_links
    return hypervisors_dict
