Deployment reports datetime DB insertion was fixed

When MySQL is used as a database backend deployment
notification reports could not be persisted due to the
fact that MySQL could not store timezone offset of
datetime.datetime.

Change-Id: Iea3b7d8d37ac68f0ebdcdcf96471a0d18a29469f
Closes-Bug: #1570933
This commit is contained in:
Stan Lagun 2016-04-18 10:49:35 -07:00
parent 9536e51fa0
commit a787d631ec

View File

@ -20,6 +20,7 @@ import oslo_messaging as messaging
from oslo_messaging import target
from oslo_service import service
from oslo_utils import timeutils
import pytz
from sqlalchemy import desc
from murano.common.helpers import token_sanitizer
@ -178,7 +179,8 @@ def report_notification(report):
status = models.Status()
if 'timestamp' in report:
report['created'] = timeutils.parse_isotime(report.pop('timestamp'))
dt = timeutils.parse_isotime(report.pop('timestamp'))
report['created'] = dt.astimezone(pytz.utc).replace(tzinfo=None)
status.update(report)
unit = session.get_session()