'Return dhcp agents hosting the given network or None if a given
network is already hosted by enough number of agents.'

def _get_dhcp_agents_hosting_network(self, plugin, context, network):

    agents_per_network = cfg.CONF.dhcp_agents_per_network
    with context.session.begin(subtransactions=True):
        network_hosted_agents = plugin.get_dhcp_agents_hosting_networks(context, [network['id']], hosts=network.get('candidate_hosts'))
        if (len(network_hosted_agents) >= agents_per_network):
            LOG.debug('Network    %s    is    already    hosted    by    enough    agents.', network['id'])
            return
    return network_hosted_agents
