Allow specific PTGs to hide from member create

By default all PTGs will be listed as available groups
and allows to select any groups.There is no way to specify
PTGs to not consider while launching a member.
As a solution, providing optional configuration parameter
GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE to specify
which group to excule based on group name regex match.

This optional parameter can be specified in openstack dashboard
local settings(openstack_dashboard/local/local_settings.py)

e.g.
GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE =
    ['*.backup_network_group_name', '*.another_group_name']

With the above definition, create member form wont show PTGs with
name ending 'backup_network_group_name' and 'another_group_name'

Change-Id: Ibda517bb8bb747e9cf205979521c6903fdef8d17
Closes-Bug: #bug/1639137
(cherry picked from commit d725eeabaf)
This commit is contained in:
ank 2016-11-04 15:31:18 +05:30
parent 7d57212deb
commit 8dfedc0293
1 changed files with 9 additions and 0 deletions

View File

@ -11,7 +11,9 @@
# under the License.
import logging
import re
from django.conf import settings
from django.core.urlresolvers import reverse
from django import shortcuts
from django.utils import html
@ -432,6 +434,13 @@ class SetGroupAction(workflows.Action):
proxy_groups = [pt.get('proxy_group_id') for pt in pts
if pt.get('proxy_group_id')]
for pt in pts:
if hasattr(settings,
'GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE'):
regexs = "(" + ")|(".join(
settings.GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE) \
+ ")"
if re.match(regexs, pt.get('name')):
continue
if pt.id in proxy_groups or pt.get('proxied_group_id'):
continue
pt.set_id_as_name_if_empty()