'Check if agent was just started.
Method returns True if agent is in its \'starting up\' period.
Return value depends on amount of networks assigned to the agent.
It doesn\'t look at latest heartbeat timestamp as it is assumed
that this method is called for agents that are considered dead.'

def agent_starting_up(self, context, agent):

    agent_dead_limit = datetime.timedelta(seconds=self.agent_dead_limit_seconds())
    network_count = context.session.query(ndab_model.NetworkDhcpAgentBinding).filter_by(dhcp_agent_id=agent['id']).count()
    additional_time = datetime.timedelta(seconds=(2 * network_count))
    LOG.debug('Checking    if    agent    starts    up    and    giving    it    additional    %s', additional_time)
    agent_expected_up = ((agent['started_at'] + agent_dead_limit) + additional_time)
    return (agent_expected_up > timeutils.utcnow())
