From f7f4755076c29931e4ed372448487068d9462f15 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Sat, 16 Jun 2012 08:39:10 +0100 Subject: [PATCH] heat API : Align time format with AWS spec - 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 --- heat/api/v1/stacks.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/heat/api/v1/stacks.py b/heat/api/v1/stacks.py index 3807a92dc5..3e6a754451 100644 --- a/heat/api/v1/stacks.py +++ b/heat/api/v1/stacks.py @@ -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