diff options
| author | Brian Lamar <brian.lamar@rackspace.com> | 2011-03-28 13:47:18 -0400 |
|---|---|---|
| committer | Brian Lamar <brian.lamar@rackspace.com> | 2011-03-28 13:47:18 -0400 |
| commit | de07a6409d575af5db748bdbfa2cc57881136d66 (patch) | |
| tree | 95b095e9d2fe84595130711763026d9ea067cc54 /nova/image | |
| parent | e043561a8d5dc0c3183ec7e3a5a44f2aa306d2fd (diff) | |
Decided to not break old format so this should work with the way Glance used to work and the way glace works now..The best of both worlds?
Diffstat (limited to 'nova/image')
| -rw-r--r-- | nova/image/glance.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py index 32c9fa6be..34fc78e71 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -230,5 +230,13 @@ def _parse_glance_iso8601_timestamp(timestamp): """ Parse a subset of iso8601 timestamps into datetime objects """ - ISO_FMT = "%Y-%m-%dT%H:%M:%S.%f" - return datetime.datetime.strptime(timestamp, ISO_FMT) + ISO_FORMATS = ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%dT%H:%M:%S"] + + for iso_format in ISO_FORMATS: + try: + return datetime.datetime.strptime(timestamp, iso_format) + except ValueError: + pass + + raise ValueError(_("""%(timestamp)s does not follow any of the \ +signatures: %(ISO_FORMATS)s""") % (locals())) |
