heat api/engine : Reworked approach to aligning with AWS date format

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>
This commit is contained in:
Steven Hardy 2012-06-18 11:30:50 +01:00
parent f7f4755076
commit 614f7868c4
3 changed files with 6 additions and 16 deletions

View 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

View 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):

View 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):
"""