from fabfile.config import *

@task
@roles('all')
def get_all_time():
    date = run("DATE=$( sudo date ); DATEMILLISEC=$( sudo date +%s ); echo $DATE; echo $DATEMILLISEC")
    return tuple(date.split('\r\n'))

@task
@roles('build')
def verify_time_all():
    result = execute('get_all_time')
    print result
    all_time = [int(date_in_millisec) for date, date_in_millisec in result.values()]
    all_time.sort()
   
    if (all_time[-1] - all_time[0]) > 120:
        raise RuntimeError("Time not synced in the nodes, Please sync and proceed:\n %s" % result)
    else:
        print "Time synced in the nodes, Proceeding to install/provision."

     

from fabfile.config import *

@task
@roles('all')
def get_all_time():
    date = run("DATE=$( sudo date ); DATEMILLISEC=$( sudo date +%s ); echo $DATE; echo $DATEMILLISEC")
    return tuple(date.split('\r\n'))

@task
@parallel
@roles('build')
def verify_time_all():
    result = execute('get_all_time')
    all_time = []
    for dates in result.values():
        try:
            (date, date_in_millisec) = dates
            all_time.append(int(date_in_millisec))
        except ValueError:
            print "ERROR: %s" %  dates
    all_time.sort()

    if (all_time[-1] - all_time[0]) > 240:
        raise RuntimeError("Time not synced in the nodes,"
                           " Please sync and proceed:\n %s %s %s" %
                           (result, all_time[-1], all_time[0]))
    else:
        print "Time synced in the nodes, Proceeding to install/provision."

Increase the time delta from 120 to 240 milli secs to decide the failure.
Increase the time delta from 120 to 240 milli secs to
decide the failure.

Change-Id: Ic51da36d79d4cd4ccac342d7242e56a23e21c07f
