From c26201c856d15d64ce243cb06813922400e88345 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Tue, 2 Dec 2014 16:11:34 +0800 Subject: [PATCH] Show the creation time for stack snapshots Creation time for snapshots is an important attribute, we should return the creation time when doing stack snapshot actions. Change-Id: Ieaedaf79bf073737ec41fba2d0252d3f4ddc0fcf Closes-Bug: #1398307 --- heat/engine/api.py | 2 ++ heat/rpc/api.py | 6 ++++-- heat/tests/test_engine_service.py | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/heat/engine/api.py b/heat/engine/api.py index 4c7bba1c96..6400cb360b 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -390,5 +390,7 @@ def format_snapshot(snapshot): rpc_api.SNAPSHOT_STATUS: snapshot.status, rpc_api.SNAPSHOT_STATUS_REASON: snapshot.status_reason, rpc_api.SNAPSHOT_DATA: snapshot.data, + rpc_api.SNAPSHOT_CREATION_TIME: timeutils.isotime( + snapshot.created_at), } return result diff --git a/heat/rpc/api.py b/heat/rpc/api.py index c6744169a5..37a7a673d4 100644 --- a/heat/rpc/api.py +++ b/heat/rpc/api.py @@ -235,14 +235,16 @@ SNAPSHOT_KEYS = ( SNAPSHOT_STACK_ID, SNAPSHOT_DATA, SNAPSHOT_STATUS, - SNAPSHOT_STATUS_REASON + SNAPSHOT_STATUS_REASON, + SNAPSHOT_CREATION_TIME, ) = ( 'id', 'name', 'stack_id', 'data', 'status', - 'status_reason' + 'status_reason', + 'creation_time' ) THREAD_MESSAGES = (THREAD_CANCEL,) = ('cancel',) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index e968a5bba5..f0b905083a 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -3588,6 +3588,7 @@ class SnapshotServiceTest(common.HeatTestCase): snapshot = self.engine.stack_snapshot( self.ctx, stack.identifier(), 'snap1') self.assertIsNotNone(snapshot['id']) + self.assertIsNotNone(snapshot['creation_time']) self.assertEqual('snap1', snapshot['name']) self.assertEqual("IN_PROGRESS", snapshot['status']) self.engine.thread_group_mgr.groups[stack.id].wait() @@ -3598,6 +3599,7 @@ class SnapshotServiceTest(common.HeatTestCase): self.assertEqual("COMPLETE", snapshot['data']['status']) self.assertEqual(stack.id, snapshot['data']['id']) self.assertIsNotNone(stack.updated_time) + self.assertIsNotNone(snapshot['creation_time']) def test_delete_snapshot_not_found(self): stack = self._create_stack() @@ -3638,7 +3640,8 @@ class SnapshotServiceTest(common.HeatTestCase): "name": "snap1", "status": "COMPLETE", "status_reason": "Stack SNAPSHOT completed successfully", - "data": stack.prepare_abandon()} + "data": stack.prepare_abandon(), + "creation_time": snapshot['creation_time']} self.assertEqual([expected], snapshots) def test_restore_snapshot(self):