2
0
mirror of https://opendev.org/x/pyghmi synced 2026-03-28 22:03:30 +00:00

Fix 'uptime' time correction attempt

When doing the attempt to correct time, the sense of comparison was
incorrect and the timestamp field was neglected.  Correct this
mistake and oversight.

Change-Id: Ia3ff187d0eaedcfea9f3b7d2c8f292162bb3bb50
This commit is contained in:
Jarrod Johnson
2016-02-29 12:51:48 -05:00
parent 02d13366ee
commit bb9436aa2e

View File

@@ -297,7 +297,7 @@ def _fix_sel_time(records, ipmicmd):
correctearly = False
inpreinit = False
newtimestamp = 0
lasttimestamp = 0
lasttimestamp = None
trimindexes = []
for index in reversed(xrange(len(records))):
record = records[index]
@@ -323,7 +323,8 @@ def _fix_sel_time(records, ipmicmd):
if not correctearly:
correctednowtime = nowtime
continue
if record['timecode'] < lasttimestamp:
if (lasttimestamp is not None and
record['timecode'] > lasttimestamp):
# Time has gone backwards in pre-init, no hope for
# accurate time
correctearly = False
@@ -331,6 +332,9 @@ def _fix_sel_time(records, ipmicmd):
continue
inpreinit = True
lasttimestamp = record['timecode']
age = correctednowtime - record['timecode']
record['timestamp'] = time.strftime(
'%Y-%m-%dT%H:%M:%S', time.localtime(time.time() - age))
else:
# We are in 'normal' time, assume we cannot go to
# pre-init time and do corrections unless time sync events
@@ -464,7 +468,7 @@ class EventHandler(object):
def _decode_standard_event(self, eventdata, event):
# Ignore the generator id for now..
if eventdata[2] != 4:
if eventdata[2] not in (3, 4):
raise pygexc.PyghmiException(
'Unrecognized Event message version {0}'.format(eventdata[2]))
sensor_type = eventdata[3]