Show 'deletion_time' for stack-list/stack-show apis
We support to get the deleted stacks by filter in stack-list api, support to show the deleted stack by stack-id, so to show the 'deletion_time' info of stacks. Change-Id: I8c55fe7f6a899ca66aa3fef15c93195c03c5aa11 Closes-Bug: #1587214
This commit is contained in:
parent
ec166faf61
commit
ccdb9c9ae6
@ -17,7 +17,8 @@
|
||||
"tags": null,
|
||||
"parent": null,
|
||||
"stack_owner": null,
|
||||
"stack_user_project_id": "71510cbd459a49ac989ca1055de7038b"
|
||||
"stack_user_project_id": "71510cbd459a49ac989ca1055de7038b",
|
||||
"deletion_time": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -567,6 +567,7 @@ Response Parameters
|
||||
- tags: tags
|
||||
- creation_time: creation_time
|
||||
- updated_time: updated_time
|
||||
- deletion_time: deleted_at
|
||||
- stack_status: stack_status
|
||||
- stack_owner: owner_id
|
||||
- stack_user_project_id: stack_user_project_id
|
||||
|
@ -212,11 +212,13 @@ def format_stack(stack, preview=False, resolve_outputs=True):
|
||||
"""
|
||||
updated_time = stack.updated_time and stack.updated_time.isoformat()
|
||||
created_time = stack.created_time or timeutils.utcnow()
|
||||
deleted_time = stack.deleted_time and stack.deleted_time.isoformat()
|
||||
info = {
|
||||
rpc_api.STACK_NAME: stack.name,
|
||||
rpc_api.STACK_ID: dict(stack.identifier()),
|
||||
rpc_api.STACK_CREATION_TIME: created_time.isoformat(),
|
||||
rpc_api.STACK_UPDATED_TIME: updated_time,
|
||||
rpc_api.STACK_DELETION_TIME: deleted_time,
|
||||
rpc_api.STACK_NOTIFICATION_TOPICS: [], # TODO(therve) Not implemented
|
||||
rpc_api.STACK_PARAMETERS: stack.parameters.map(six.text_type),
|
||||
rpc_api.STACK_DESCRIPTION: stack.t[stack.t.DESCRIPTION],
|
||||
@ -255,6 +257,8 @@ def format_stack_db_object(stack):
|
||||
"""
|
||||
updated_time = stack.updated_at and stack.updated_at.isoformat()
|
||||
created_time = stack.created_at
|
||||
deleted_time = stack.deleted_at and stack.deleted_at.isoformat()
|
||||
|
||||
tags = None
|
||||
if stack.tags:
|
||||
tags = [t.tag for t in stack.tags]
|
||||
@ -267,6 +271,7 @@ def format_stack_db_object(stack):
|
||||
rpc_api.STACK_STATUS_DATA: stack.status_reason,
|
||||
rpc_api.STACK_CREATION_TIME: created_time.isoformat(),
|
||||
rpc_api.STACK_UPDATED_TIME: updated_time,
|
||||
rpc_api.STACK_DELETION_TIME: deleted_time,
|
||||
rpc_api.STACK_OWNER: stack.username,
|
||||
rpc_api.STACK_PARENT: stack.owner_id,
|
||||
rpc_api.STACK_USER_PROJECT_ID: stack.stack_user_project_id,
|
||||
|
@ -128,7 +128,7 @@ class Stack(collections.Mapping):
|
||||
nested_depth=0, strict_validate=True, convergence=False,
|
||||
current_traversal=None, tags=None, prev_raw_template_id=None,
|
||||
current_deps=None, cache_data=None, resource_validate=True,
|
||||
service_check_defer=False):
|
||||
service_check_defer=False, deleted_time=None):
|
||||
|
||||
"""Initialise the Stack.
|
||||
|
||||
@ -178,6 +178,7 @@ class Stack(collections.Mapping):
|
||||
self.stack_user_project_id = stack_user_project_id
|
||||
self.created_time = created_time
|
||||
self.updated_time = updated_time
|
||||
self.deleted_time = deleted_time
|
||||
self.user_creds_id = user_creds_id
|
||||
self.nested_depth = nested_depth
|
||||
self.convergence = convergence
|
||||
@ -529,7 +530,8 @@ class Stack(collections.Mapping):
|
||||
current_traversal=stack.current_traversal,
|
||||
prev_raw_template_id=stack.prev_raw_template_id,
|
||||
current_deps=stack.current_deps, cache_data=cache_data,
|
||||
nested_depth=stack.nested_depth)
|
||||
nested_depth=stack.nested_depth,
|
||||
deleted_time=stack.deleted_at)
|
||||
|
||||
def get_kwargs_for_cloning(self, keep_status=False, only_db=False):
|
||||
"""Get common kwargs for calling Stack() for cloning.
|
||||
|
@ -346,6 +346,7 @@ class FormatTest(common.HeatTestCase):
|
||||
expected_stack_info = {
|
||||
'capabilities': [],
|
||||
'creation_time': '1970-01-01T00:00:00',
|
||||
'deletion_time': None,
|
||||
'description': 'No description',
|
||||
'disable_rollback': True,
|
||||
'notification_topics': [],
|
||||
|
@ -469,6 +469,8 @@ class StackServiceTest(common.HeatTestCase):
|
||||
for s in sl:
|
||||
self.assertIn('creation_time', s)
|
||||
self.assertIn('updated_time', s)
|
||||
self.assertIn('deletion_time', s)
|
||||
self.assertIsNone(s['deletion_time'])
|
||||
self.assertIn('stack_identity', s)
|
||||
self.assertIsNotNone(s['stack_identity'])
|
||||
self.assertIn('stack_name', s)
|
||||
@ -892,6 +894,8 @@ class StackServiceTest(common.HeatTestCase):
|
||||
s = sl[0]
|
||||
self.assertIn('creation_time', s)
|
||||
self.assertIn('updated_time', s)
|
||||
self.assertIn('deletion_time', s)
|
||||
self.assertIsNone(s['deletion_time'])
|
||||
self.assertIn('stack_identity', s)
|
||||
self.assertIsNotNone(s['stack_identity'])
|
||||
self.assertIn('stack_name', s)
|
||||
@ -913,6 +917,8 @@ class StackServiceTest(common.HeatTestCase):
|
||||
s = sl[0]
|
||||
self.assertIn('creation_time', s)
|
||||
self.assertIn('updated_time', s)
|
||||
self.assertIn('deletion_time', s)
|
||||
self.assertIsNone(s['deletion_time'])
|
||||
self.assertIn('stack_identity', s)
|
||||
self.assertIsNotNone(s['stack_identity'])
|
||||
self.assertIn('stack_name', s)
|
||||
|
@ -387,7 +387,8 @@ class StackTest(common.HeatTestCase):
|
||||
current_traversal=self.stack.current_traversal,
|
||||
prev_raw_template_id=None,
|
||||
current_deps=None, cache_data=None,
|
||||
nested_depth=0)
|
||||
nested_depth=0,
|
||||
deleted_time=None)
|
||||
|
||||
self.m.ReplayAll()
|
||||
stack.Stack.load(self.ctx, stack_id=self.stack.id)
|
||||
|
Loading…
Reference in New Issue
Block a user