diff options
author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-07-29 19:54:54 +0000 |
---|---|---|
committer | Tarmac <> | 2011-07-29 19:54:54 +0000 |
commit | bdcfaa5b927a096f507fb0f7e2d81989173957f8 (patch) | |
tree | a94a7f9bfb3a863f31f31fee2770bfbfa9bcd086 /nova/utils.py | |
parent | 6703e33a68d0653f486d679337b4dfc4239eba34 (diff) | |
parent | 277b63bd933f0c1bf9209f3c52d1e914fc1d2382 (diff) | |
download | nova-bdcfaa5b927a096f507fb0f7e2d81989173957f8.tar.gz nova-bdcfaa5b927a096f507fb0f7e2d81989173957f8.tar.xz nova-bdcfaa5b927a096f507fb0f7e2d81989173957f8.zip |
Round 1 of changes for keystone integration.
* Modified request context to allow it to hold all of the relevant data from the auth component.
* Pulled out access to AuthManager from as many places as possible
* Massive cleanup of unit tests
* Made the openstack api fakes use fake Authentication by default
There are now only a few places that are using auth manager:
* Authentication middleware for ec2 api (will move to stand-alone middleware)
* Authentication middleware for os api (will be deprecated in favor of keystone)
* Accounts and Users apis for os (will be switched to keystone or deprecated)
* Ec2 admin api for users and projects (will be removed)
* Nova-manage user and project commands (will be deprecated and removed with AuthManager)
* Tests that test the above sections (will be converted or removed with their relevant section)
* Tests for auth manager
* Pipelib (authman can be removed once ec2 stand-alone middleware is in place)
* xen_api (for getting images from old objectstore. I think this can be removed)
Vish
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/nova/utils.py b/nova/utils.py index 8784a227d..737903f81 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -19,7 +19,6 @@ """Utilities and helper functions.""" -import base64 import datetime import functools import inspect @@ -30,7 +29,6 @@ import os import random import re import socket -import string import struct import sys import time @@ -50,7 +48,8 @@ from nova import version LOG = logging.getLogger("nova.utils") -TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" +ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" +PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" FLAGS = flags.FLAGS @@ -361,16 +360,26 @@ def clear_time_override(): utcnow.override_time = None -def isotime(at=None): - """Returns iso formatted utcnow.""" +def strtime(at=None, fmt=PERFECT_TIME_FORMAT): + """Returns formatted utcnow.""" if not at: at = utcnow() - return at.strftime(TIME_FORMAT) + return at.strftime(fmt) + + +def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT): + """Turn a formatted time back into a datetime.""" + return datetime.datetime.strptime(timestr, fmt) + + +def isotime(at=None): + """Returns iso formatted utcnow.""" + return strtime(at, ISO_TIME_FORMAT) def parse_isotime(timestr): """Turn an iso formatted time back into a datetime.""" - return datetime.datetime.strptime(timestr, TIME_FORMAT) + return parse_strtime(timestr, ISO_TIME_FORMAT) def parse_mailmap(mailmap='.mailmap'): |