]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat API : Align time format with AWS spec
authorSteven Hardy <shardy@redhat.com>
Sat, 16 Jun 2012 07:39:10 +0000 (08:39 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 18 Jun 2012 08:31:27 +0000 (09:31 +0100)
- Reformat ListStacks/DescribeStacks responses to align time format with AWS spec
- Remove duplicate member tags in DescribeStacks (now handled by XMLResponseSerializer)
ref #125

Change-Id: Ib001acba591dba52f3f56052427d2b298d781ea0
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/api/v1/stacks.py

index 3807a92dc5b8fb4f01fdda20b2859cca25f54e2d..3e6a754451c2d0afc3992abd05536f4bdd1b48aa 100644 (file)
@@ -22,6 +22,7 @@ import logging
 import os
 import socket
 import sys
+import re
 import urlparse
 import webob
 from webob.exc import (HTTPNotFound,
@@ -48,6 +49,13 @@ class StackController(object):
     def __init__(self, options):
         self.options = options
 
+    # convert date so it is aligned with aws date spec
+    # engine returns UTC date "2012-06-15 18:24:32"
+    # AWS format is "2012-06-15T18:24:32Z"
+    def _to_api_date(self, db_date):
+        return re.sub("([0-9]+-[0-9]+-[0-9]+) ([0-9]+:[0-9]+:[0-9]+)$",
+                        "\\1T\\2Z", str(db_date))
+
     def list(self, req):
         """
         Returns the following information for all stacks:
@@ -65,6 +73,7 @@ class StackController(object):
         summaries = results['StackSummaries']
         if stack_list is not None:
             for s in stack_list['stacks']:
+                s['CreationTime'] = self._to_api_date(s['CreationTime'])
                 summaries.append(s)
 
         return res
@@ -88,8 +97,10 @@ class StackController(object):
         res = {'DescribeStacksResult': {'Stacks': []}}
         stacks = res['DescribeStacksResult']['Stacks']
         for s in stack_list['stacks']:
-            mem = {'member': s}
-            stacks.append(mem)
+            s['CreationTime'] = self._to_api_date(s['CreationTime'])
+            s['LastUpdatedTimestamp'] = self._to_api_date(
+                s['LastUpdatedTimestamp'])
+            stacks.append(s)
 
         return res