'Checks if the server and the agent times are in sync.
Method checks if the agent time is in sync with the server time
on start up. Ignores it, on subsequent re-connects.'

def _check_clock_sync_on_agent_start(self, agent_state, agent_time):

    if agent_state.get('start_flag'):
        time_server_now = timeutils.utcnow()
        diff = abs(timeutils.delta_seconds(time_server_now, agent_time))
        if (diff > cfg.CONF.agent_down_time):
            agent_name = agent_state['agent_type']
            time_agent = datetime.datetime.isoformat(agent_time)
            host = agent_state['host']
            log_dict = {'host': host, 'agent_name': agent_name, 'agent_time': time_agent, 'threshold': cfg.CONF.agent_down_time, 'serv_time': datetime.datetime.isoformat(time_server_now), 'diff': diff}
            LOG.error(_LE('Message    received    from    the    host:    %(host)s    during    the    registration    of    %(agent_name)s    has    a    timestamp:    %(agent_time)s.    This    differs    from    the    current    server    timestamp:    %(serv_time)s    by    %(diff)s    seconds,    which    is    more    than    the    threshold    agent    downtime:    %(threshold)s.'), log_dict)
