Browse Source

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
ank 2 years ago
parent
commit
d725eeabaf
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      gbpui/panels/policytargets/workflows.py

+ 9
- 0
gbpui/panels/policytargets/workflows.py View File

@@ -11,7 +11,9 @@
11 11
 #    under the License.
12 12
 
13 13
 import logging
14
+import re
14 15
 
16
+from django.conf import settings
15 17
 from django.core.urlresolvers import reverse
16 18
 from django import shortcuts
17 19
 from django.utils import html
@@ -432,6 +434,13 @@ class SetGroupAction(workflows.Action):
432 434
             proxy_groups = [pt.get('proxy_group_id') for pt in pts
433 435
                             if pt.get('proxy_group_id')]
434 436
             for pt in pts:
437
+                if hasattr(settings,
438
+                           'GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE'):
439
+                    regexs = "(" + ")|(".join(
440
+                        settings.GBPUI_HIDE_PTG_NAMES_FROM_MEMBER_CREATE) \
441
+                        + ")"
442
+                    if re.match(regexs, pt.get('name')):
443
+                        continue
435 444
                 if pt.id in proxy_groups or pt.get('proxied_group_id'):
436 445
                     continue
437 446
                 pt.set_id_as_name_if_empty()

Loading…
Cancel
Save