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
This commit is contained in:
huangtianhua 2014-12-02 16:11:34 +08:00
parent a3f8c810b1
commit c26201c856
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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',)

View File

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