Add "Edit Port Security Groups" action

This commit adds a new action "Edit Port Security Groups"
which jumps the interfaces tab of the instance detail page.

In addition, a warning message is added to the "Edit Security Groups"
form because if a user change security groups as an instance level
the change will be applied to all interfaces of the instance, so
it would be nice if we can provide a good navigation to a page
of editting security groups per port.

Previously, UpdateMembersStep does not support help_text_template option.
To use a bold tag in the added help message, we need to use a template
instead of help_text, so _workflow_step_update_members.html is updated.

Closes-Bug: #1750147
Change-Id: I71437a376b94cab90df0e423aa7e1d2d0d8387ee
This commit is contained in:
Akihiro Motoki 2018-02-17 23:24:18 +09:00
parent ff5b622da5
commit 3adff90a37
5 changed files with 33 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<div class="membership {{ step.slug }}_membership dropdown_fix" data-show-roles="{{ step.show_roles }}">
<div class="header">
<div class="help_text">{{ step.help_text }}</div>
<div class="help_text">{{ step.get_help_text }}</div>
<div class="row">
<div class="col-xs-6">

View File

@ -478,6 +478,17 @@ class EditInstanceSecurityGroups(EditInstance):
request.user.tenant_id == instance.tenant_id)
class EditPortSecurityGroups(tables.LinkAction):
name = "edit_port_secgroups"
verbose_name = _("Edit Port Security Groups")
url = "horizon:project:instances:detail"
icon = "pencil"
def get_link_url(self, instance):
base_url = urls.reverse(self.url, args=[instance.id])
return '%s?tab=%s__%s' % (base_url, 'instance_details', 'interfaces')
class CreateSnapshot(policy.PolicyTargetMixin, tables.LinkAction):
name = "snapshot"
verbose_name = _("Create Snapshot")
@ -1253,7 +1264,9 @@ class InstancesTable(tables.DataTable):
AttachInterface, DetachInterface, EditInstance,
AttachVolume, DetachVolume,
UpdateMetadata, DecryptInstancePassword,
EditInstanceSecurityGroups, ConsoleLink, LogLink,
EditInstanceSecurityGroups,
EditPortSecurityGroups,
ConsoleLink, LogLink,
TogglePause, ToggleSuspend, ToggleShelve,
ResizeLink, LockInstance, UnlockInstance,
SoftRebootInstance, RebootInstance,

View File

@ -0,0 +1,15 @@
{% load i18n %}
<p>
{% blocktrans trimmed %}
Add and remove security groups to this instance from the list of available
security groups.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
<b>Warning:</b> If you change security groups here, the change will be applied to
all interfaces of the instance. If you have multiple interfaces on this
instance and apply different security groups per port,
use "Edit Port Security Groups" action instead.
{% endblocktrans %}
</p>

View File

@ -54,13 +54,12 @@ class UpdateInstanceSecurityGroupsAction(sg_base.BaseSecurityGroupsAction):
class Meta(object):
name = _("Security Groups")
slug = INSTANCE_SEC_GROUP_SLUG
help_text_template = 'project/instances/_edit_security_group_help.html'
class UpdateInstanceSecurityGroups(sg_base.BaseSecurityGroups):
action_class = UpdateInstanceSecurityGroupsAction
members_list_title = _("Instance Security Groups")
help_text = _("Add and remove security groups to this instance "
"from the list of available security groups.")
depends_on = ("instance_id", "target_tenant_id")
def allowed(self, request):

View File

@ -4,3 +4,5 @@ features:
"Interfaces" tab is added to the instance detail page. The new tab shows
a list of ports attached to an instance. Users now have an easy way to
access the list of ports of the instance and edit security groups per port.
In addition, "Edit Port Security Groups" menu is added as an action of
the instance table.