'Get the list of agents who can provide services.'

def _get_enabled_agents(self, context, network, agents, method, payload):

    if (not agents):
        return []
    network_id = network['id']
    enabled_agents = agents
    if (not cfg.CONF.enable_services_on_agents_with_admin_state_down):
        enabled_agents = [x for x in agents if x.admin_state_up]
    active_agents = [x for x in agents if x.is_active]
    len_enabled_agents = len(enabled_agents)
    len_active_agents = len(active_agents)
    if (len_active_agents < len_enabled_agents):
        LOG.warning(_LW("Only    %(active)d    of    %(total)d    DHCP    agents    associated    with    network    '%(net_id)s'    are    marked    as    active,    so    notifications    may    be    sent    to    inactive    agents."), {'active': len_active_agents, 'total': len_enabled_agents, 'net_id': network_id})
    if (not enabled_agents):
        num_ports = self.plugin.get_ports_count(context, {'network_id': [network_id]})
        notification_required = ((num_ports > 0) and (len(network['subnets']) >= 1))
        if notification_required:
            LOG.error(_LE('Will    not    send    event    %(method)s    for    network    %(net_id)s:    no    agent    available.    Payload:    %(payload)s'), {'method': method, 'net_id': network_id, 'payload': payload})
    return enabled_agents
