]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat api/engine : Reworked approach to aligning with AWS date format
authorSteven Hardy <shardy@redhat.com>
Mon, 18 Jun 2012 10:30:50 +0000 (11:30 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 18 Jun 2012 10:30:50 +0000 (11:30 +0100)
Modifies heat internal default date-string representation to match AWS spec
Note heat.common.utils.strtime default format loses sub-second precision
Avoids having to regex mangle datetime string format
ref #125

Change-Id: I1347e82b1c3ccac5eac7c85858cf8009723547c2
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/api/v1/stacks.py
heat/common/utils.py
heat/engine/manager.py

index 3e6a754451c2d0afc3992abd05536f4bdd1b48aa..5831163615092deeba6d8eb3c3fce94dd22b4287 100644 (file)
@@ -49,13 +49,6 @@ 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:
@@ -73,7 +66,6 @@ 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
@@ -97,9 +89,6 @@ class StackController(object):
         res = {'DescribeStacksResult': {'Stacks': []}}
         stacks = res['DescribeStacksResult']['Stacks']
         for s in stack_list['stacks']:
-            s['CreationTime'] = self._to_api_date(s['CreationTime'])
-            s['LastUpdatedTimestamp'] = self._to_api_date(
-                s['LastUpdatedTimestamp'])
             stacks.append(s)
 
         return res
index f39104c721a68d3839c3ed7a31cc8e898de96afe..666d3ae4132df588e708f1c7bf3eae023eac30a2 100644 (file)
@@ -32,7 +32,7 @@ from eventlet.green import subprocess
 from heat.openstack.common import exception
 from heat.openstack.common import timeutils
 
-PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
+PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
 
 
 def chunkreadable(iter, chunk_size=65536):
index 46a3c293c7ec9747367f3729842d56dfe2d5d2df..5de0ffe78d11a9093240c53bdf49fc92d79c7cbe 100644 (file)
@@ -27,6 +27,7 @@ import eventlet
 from heat import manager
 from heat.db import api as db_api
 from heat.common import config
+from heat.common import utils as heat_utils
 from heat.engine import parser
 from heat.engine import resources
 from heat.engine import watchrule
@@ -150,7 +151,7 @@ class EngineManager(manager.Manager):
             mem = {}
             mem['StackId'] = s.id
             mem['StackName'] = s.name
-            mem['CreationTime'] = str(s.created_at)
+            mem['CreationTime'] = heat_utils.strtime(s.created_at)
             mem['TemplateDescription'] = ps.t.get('Description',
                                                    'No description')
             mem['StackStatus'] = ps.t.get('stack_status', 'unknown')
@@ -176,8 +177,8 @@ class EngineManager(manager.Manager):
             mem = {}
             mem['StackId'] = s.id
             mem['StackName'] = s.name
-            mem['CreationTime'] = str(s.created_at)
-            mem['LastUpdatedTimestamp'] = str(s.updated_at)
+            mem['CreationTime'] = heat_utils.strtime(s.created_at)
+            mem['LastUpdatedTimestamp'] = heat_utils.strtime(s.updated_at)
             mem['NotificationARNs'] = 'TODO'
             mem['Parameters'] = ps.t['Parameters']
             mem['TimeoutInMinutes'] = ps.t.get('Timeout', '60')
@@ -255,7 +256,7 @@ class EngineManager(manager.Manager):
         greenpool.spawn_n(stack.create)
 
         return {'stack': {'id': new_s.id, 'name': new_s.name,
-                'CreationTime': str(new_s.created_at)}}
+                'CreationTime': heat_utils.strtime(new_s.created_at)}}
 
     def validate_template(self, context, template, params):
         """