diff options
author | Petr Spacek <pspacek@redhat.com> | 2015-06-30 14:04:13 +0200 |
---|---|---|
committer | Tomas Babej <tbabej@redhat.com> | 2015-07-01 12:25:52 +0200 |
commit | fe6819eb9d7d9f84616daadb5f07072a3dfa02b1 (patch) | |
tree | 45adb7a565803ef090798bf5765282c6778df7db /daemons | |
parent | 57429c1cfa73dbcb45f705dd1723c822be4b6617 (diff) | |
download | freeipa-fe6819eb9d7d9f84616daadb5f07072a3dfa02b1.tar.gz freeipa-fe6819eb9d7d9f84616daadb5f07072a3dfa02b1.tar.xz freeipa-fe6819eb9d7d9f84616daadb5f07072a3dfa02b1.zip |
DNSSEC: Store time & date key metadata in UTC.
OpenDNSSEC stores key metadata in local time zone but BIND needs
timestamps in UTC. UTC will be stored in LDAP.
https://fedorahosted.org/freeipa/ticket/4657
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'daemons')
-rwxr-xr-x | daemons/dnssec/ipa-ods-exporter | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/daemons/dnssec/ipa-ods-exporter b/daemons/dnssec/ipa-ods-exporter index 03dcfbc83..4c6649c2f 100755 --- a/daemons/dnssec/ipa-ods-exporter +++ b/daemons/dnssec/ipa-ods-exporter @@ -17,6 +17,7 @@ Purpose of this replacement is to upload keys generated by OpenDNSSEC to LDAP. from binascii import hexlify from datetime import datetime +import dateutil.tz import dns.dnssec import fcntl import logging @@ -80,7 +81,12 @@ def datetime2ldap(dt): return dt.strftime(ipalib.constants.LDAP_GENERALIZED_TIME_FORMAT) def sql2datetime(sql_time): - return datetime.strptime(sql_time, "%Y-%m-%d %H:%M:%S") + """Convert SQL date format from local time zone into UTC.""" + localtz = dateutil.tz.tzlocal() + localtime = datetime.strptime(sql_time, "%Y-%m-%d %H:%M:%S").replace( + tzinfo=localtz) + utctz = dateutil.tz.gettz('UTC') + return localtime.astimezone(utctz) def sql2datetimes(row): row2key_map = {'generate': 'idnsSecKeyCreated', |