Add "Suspend" and "Resume" actions to Stacks table
This patch set adds "Suspend Stack" and "Resume Stack" buttons to Stacks table to provide user with a possibility to suspend and resume stack, like it is already implemented in CLI. Partially implements blueprint: heat-ui-improvement Change-Id: I6ea8cb7f342fdd8fcfd124012aefc66d9d898410
This commit is contained in:
parent
78fc7e6ea6
commit
b2c07ad64e
|
@ -130,6 +130,14 @@ def action_check(request, stack_id):
|
||||||
return heatclient(request).actions.check(stack_id)
|
return heatclient(request).actions.check(stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
def action_suspend(request, stack_id):
|
||||||
|
return heatclient(request).actions.suspend(stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
def action_resume(request, stack_id):
|
||||||
|
return heatclient(request).actions.resume(stack_id)
|
||||||
|
|
||||||
|
|
||||||
def resource_types_list(request):
|
def resource_types_list(request):
|
||||||
return heatclient(request).resource_types.list()
|
return heatclient(request).resource_types.list()
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
"cloudformation:DescribeStackResources": "rule:deny_stack_user",
|
"cloudformation:DescribeStackResources": "rule:deny_stack_user",
|
||||||
"cloudformation:ListStackResources": "rule:deny_stack_user",
|
"cloudformation:ListStackResources": "rule:deny_stack_user",
|
||||||
"cloudformation:CheckStack": "rule:deny_stack_user",
|
"cloudformation:CheckStack": "rule:deny_stack_user",
|
||||||
|
"cloudformation:SuspendStack": "rule:deny_stack_user",
|
||||||
|
"cloudformation:ResumeStack": "rule:deny_stack_user",
|
||||||
|
|
||||||
"cloudwatch:DeleteAlarms": "rule:deny_stack_user",
|
"cloudwatch:DeleteAlarms": "rule:deny_stack_user",
|
||||||
"cloudwatch:DescribeAlarmHistory": "rule:deny_stack_user",
|
"cloudwatch:DescribeAlarmHistory": "rule:deny_stack_user",
|
||||||
|
|
|
@ -61,6 +61,56 @@ class CheckStack(tables.BatchAction):
|
||||||
api.heat.action_check(request, stack_id)
|
api.heat.action_check(request, stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
class SuspendStack(tables.BatchAction):
|
||||||
|
name = "suspend"
|
||||||
|
verbose_name = _("Suspend Stack")
|
||||||
|
policy_rules = (("orchestration", "cloudformation:SuspendStack"),)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def action_present(count):
|
||||||
|
return ungettext_lazy(
|
||||||
|
u"Suspend Stack",
|
||||||
|
u"Suspend Stacks",
|
||||||
|
count
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def action_past(count):
|
||||||
|
return ungettext_lazy(
|
||||||
|
u"Suspended Stack",
|
||||||
|
u"Suspended Stacks",
|
||||||
|
count
|
||||||
|
)
|
||||||
|
|
||||||
|
def action(self, request, stack_id):
|
||||||
|
api.heat.action_suspend(request, stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
class ResumeStack(tables.BatchAction):
|
||||||
|
name = "resume"
|
||||||
|
verbose_name = _("Resume Stack")
|
||||||
|
policy_rules = (("orchestration", "cloudformation:ResumeStack"),)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def action_present(count):
|
||||||
|
return ungettext_lazy(
|
||||||
|
u"Resume Stack",
|
||||||
|
u"Resume Stacks",
|
||||||
|
count
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def action_past(count):
|
||||||
|
return ungettext_lazy(
|
||||||
|
u"Resumed Stack",
|
||||||
|
u"Resumed Stacks",
|
||||||
|
count
|
||||||
|
)
|
||||||
|
|
||||||
|
def action(self, request, stack_id):
|
||||||
|
api.heat.action_resume(request, stack_id)
|
||||||
|
|
||||||
|
|
||||||
class ChangeStackTemplate(tables.LinkAction):
|
class ChangeStackTemplate(tables.LinkAction):
|
||||||
name = "edit"
|
name = "edit"
|
||||||
verbose_name = _("Change Stack Template")
|
verbose_name = _("Change Stack Template")
|
||||||
|
@ -152,8 +202,16 @@ class StacksTable(tables.DataTable):
|
||||||
pagination_param = 'stack_marker'
|
pagination_param = 'stack_marker'
|
||||||
status_columns = ["status", ]
|
status_columns = ["status", ]
|
||||||
row_class = StacksUpdateRow
|
row_class = StacksUpdateRow
|
||||||
table_actions = (LaunchStack, CheckStack, DeleteStack,)
|
table_actions = (LaunchStack,
|
||||||
row_actions = (CheckStack, ChangeStackTemplate, DeleteStack,)
|
CheckStack,
|
||||||
|
SuspendStack,
|
||||||
|
ResumeStack,
|
||||||
|
DeleteStack,)
|
||||||
|
row_actions = (CheckStack,
|
||||||
|
SuspendStack,
|
||||||
|
ResumeStack,
|
||||||
|
ChangeStackTemplate,
|
||||||
|
DeleteStack,)
|
||||||
|
|
||||||
|
|
||||||
def get_resource_url(obj):
|
def get_resource_url(obj):
|
||||||
|
|
|
@ -679,6 +679,22 @@ class StackTests(test.TestCase):
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
|
def test_suspend_stack(self):
|
||||||
|
stack = self.stacks.first()
|
||||||
|
form_data = {"action": "stacks__suspend__%s" % stack.id}
|
||||||
|
res = self.client.post(INDEX_URL, form_data)
|
||||||
|
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
|
def test_resume_stack(self):
|
||||||
|
stack = self.stacks.first()
|
||||||
|
form_data = {"action": "stacks__resume__%s" % stack.id}
|
||||||
|
res = self.client.post(INDEX_URL, form_data)
|
||||||
|
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
|
|
||||||
class TemplateFormTests(test.TestCase):
|
class TemplateFormTests(test.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue