From d725eeabaffebc2ac300b9052f25b2047950860e Mon Sep 17 00:00:00 2001 From: ank Date: Fri, 4 Nov 2016 15:31:18 +0530 Subject: [PATCH] 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 --- gbpui/panels/policytargets/workflows.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gbpui/panels/policytargets/workflows.py b/gbpui/panels/policytargets/workflows.py index 0088b35..8518154 100644 --- a/gbpui/panels/policytargets/workflows.py +++ b/gbpui/panels/policytargets/workflows.py @@ -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()