diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-11 17:06:42 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-11 17:06:42 +0000 |
| commit | f220bf679086fdb3fbb01fd77fc2bb7234c121fe (patch) | |
| tree | 6a84c5d8fddf1e205aaf8eec3451a3bf62931245 /nova/utils.py | |
| parent | 0c8d9c749a5d697c49ba45c08ba716c47809e2ab (diff) | |
| parent | 2fdd73816c56b578a65466db4e5a86b9b191e1c1 (diff) | |
| download | nova-f220bf679086fdb3fbb01fd77fc2bb7234c121fe.tar.gz nova-f220bf679086fdb3fbb01fd77fc2bb7234c121fe.tar.xz nova-f220bf679086fdb3fbb01fd77fc2bb7234c121fe.zip | |
Merge "Refactor instance_usage_audit. Add audit tasklog."
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nova/utils.py b/nova/utils.py index b9af41fca..86cbdce1d 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -299,7 +299,7 @@ EASIER_PASSWORD_SYMBOLS = ('23456789', # Removed: 0, 1 'ABCDEFGHJKLMNPQRSTUVWXYZ') # Removed: I, O -def last_completed_audit_period(unit=None): +def last_completed_audit_period(unit=None, before=None): """This method gives you the most recently *completed* audit period. arguments: @@ -311,6 +311,8 @@ def last_completed_audit_period(unit=None): like so: 'day@18' This will begin the period at 18:00 UTC. 'month@15' starts a monthly period on the 15th, and year@3 begins a yearly one on March 1st. + before: Give the audit period most recently completed before + <timestamp>. Defaults to now. returns: 2 tuple of datetimes (begin, end) @@ -324,7 +326,10 @@ def last_completed_audit_period(unit=None): unit, offset = unit.split("@", 1) offset = int(offset) - rightnow = timeutils.utcnow() + if before is not None: + rightnow = before + else: + rightnow = timeutils.utcnow() if unit not in ('month', 'day', 'year', 'hour'): raise ValueError('Time period must be hour, day, month or year') if unit == 'month': |
