summaryrefslogtreecommitdiff
path: root/trove/quota
diff options
context:
space:
mode:
authorAmrith Kumar <amrith@tesora.com>2016-06-07 08:15:24 -0400
committerAmrith Kumar <amrith.kumar@gmail.com>2017-06-09 16:22:11 +0000
commit109ff949511c0185ab1dd0beffeb03a8a3332005 (patch)
tree75adba86b2c07ee9da54c7ea6e8896358f6f2952 /trove/quota
parentfb870b306ec044e8100fe67886d20be84f5807ef (diff)
downloadtrove-109ff949511c0185ab1dd0beffeb03a8a3332005.tar.gz
Handle isotime deprecation in oslo_utils.timeutils
oslo_utils.timeutils is deprecating isotime(). In reality they are deprecating some other things as well but Trove doesn't (currently) use any of those things. Much has been written on the subject of this deprecation. I think the proposal to merely replace isotime with datetime.datetime.isoformat() is a little simplistic. Well intentioned, but nonetheless I believe that it is simplistic. The primary issue I could find with oslo_utils.timeutils.isotime() was the fact that it was naive. I think it could well have been fixed in oslo_utils but for whatever reason(s) oslo decided not to want to go that route. The primary challenge from Trove's perspective is that I want to respect the existing API contract while at the same time get an implementation of time handling that is not identical in its flaws with oslo_utils.timeutils.isotime(). This change set attempts to address that by making trove.common.timeutils.isotime() that is aware. It also implements a utcnow_aware() function that is aware. ISO 8601 allows for four representations of timezone and those are <time>Z <time>[+-]hh:mm <time>[+-]hhmm <time>[+-]hh Trove conventionally used the first one, even if the time wasn't really a UTC time. That's one of the things being fixed here. In review cp16net asked whether this change removes the 'Z' at the end of time strings generated by the isotime() function. The answer is NO. The new isotime() function performs identical to the old and now deprecated function in oslo_utils.timeutils for UTC (Z) times. There was a utcnow() function in trove.common.utils which just wrapped datetime.datetime.utcnow(). That has been moved now to trove.common.timeutils with the other new time related functions. There were a couple of places in Trove where code was using datetime.now() which was not ideal. Those have been corrected now as well. Unit tests have been proposed for the new routines. Closes-Bug: #1532120 Change-Id: Ic5abf6669edd4f1a9fd62e61f437565aa887aebe
Diffstat (limited to 'trove/quota')
-rw-r--r--trove/quota/models.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/trove/quota/models.py b/trove/quota/models.py
index 64e225c0..31b7542d 100644
--- a/trove/quota/models.py
+++ b/trove/quota/models.py
@@ -14,6 +14,7 @@
from trove.common import cfg
+from trove.common import timeutils
from trove.common import utils
from trove.db import models as dbmodels
@@ -31,8 +32,8 @@ class Quota(dbmodels.DatabaseModelBase):
'hard_limit', 'id']
def __init__(self, tenant_id, resource, hard_limit,
- id=utils.generate_uuid(), created=utils.utcnow(),
- update=utils.utcnow()):
+ id=utils.generate_uuid(), created=timeutils.utcnow(),
+ update=timeutils.utcnow()):
self.tenant_id = tenant_id
self.resource = resource
self.hard_limit = hard_limit