diff options
| author | Ken Pepple <ken.pepple@gmail.com> | 2011-02-21 12:41:15 -0800 |
|---|---|---|
| committer | Ken Pepple <ken.pepple@gmail.com> | 2011-02-21 12:41:15 -0800 |
| commit | 02e196192ea1f8be22c31828266b177d14d123cd (patch) | |
| tree | 2e74aa9d99249348d86badfbb9b3fc0bfb582ae1 /nova/api | |
| parent | 89a63f53116b04a8d0681265ba8ce71eeeb5be0b (diff) | |
| download | nova-02e196192ea1f8be22c31828266b177d14d123cd.tar.gz nova-02e196192ea1f8be22c31828266b177d14d123cd.tar.xz nova-02e196192ea1f8be22c31828266b177d14d123cd.zip | |
make sure that ec2 response times are xs:dateTime parsable
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/apirequest.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/api/ec2/apirequest.py b/nova/api/ec2/apirequest.py index 00b527d62..2b1acba5a 100644 --- a/nova/api/ec2/apirequest.py +++ b/nova/api/ec2/apirequest.py @@ -46,6 +46,11 @@ def _underscore_to_xmlcase(str): return res[:1].lower() + res[1:] +def _database_to_isoformat(datetimeobj): + """Return a xs:dateTime parsable string from datatime""" + return datetimeobj.strftime("%Y-%m-%dT%H:%M:%SZ") + + def _try_convert(value): """Return a non-string if possible""" if value == 'None': @@ -173,7 +178,8 @@ class APIRequest(object): elif isinstance(data, bool): data_el.appendChild(xml.createTextNode(str(data).lower())) elif isinstance(data, datetime.datetime): - data_el.appendChild(xml.createTextNode(data.isoformat())) + data_el.appendChild( + xml.createTextNode(_database_to_isoformat(data))) elif data != None: data_el.appendChild(xml.createTextNode(str(data))) |
