Skip to content

Commit

Permalink
Always display the Domains panel for Keystone V3
Browse files Browse the repository at this point in the history
The Domains panel is only displayed when the user explicitly set
the OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT to True and keystone
supports V3.

The change allows the Domain panel to be displayed even if the flag
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT is False. In this case, the
CRUD actions will not be available in the panel.

If the local_settings.py.example is taken as is, Keystone V3 is
assumed to be available. The Domain panel should also be available.

Change-Id: Ifa81c6f106ba98a192a163aeb80f0ff92888d954
Fixes: bug 1211667
  • Loading branch information
lin-hua-cheng committed Aug 14, 2013
1 parent 7e7965f commit 160ea12
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion openstack_dashboard/api/keystone.py
Expand Up @@ -515,7 +515,11 @@ def get_user_ec2_credentials(request, user_id, access_token):

def keystone_can_edit_domain():
backend_settings = getattr(settings, "OPENSTACK_KEYSTONE_BACKEND", {})
return backend_settings.get('can_edit_domain', True)
can_edit_domain = backend_settings.get('can_edit_domain', True)
multi_domain_support = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)
return can_edit_domain and multi_domain_support


def keystone_can_edit_user():
Expand Down
8 changes: 1 addition & 7 deletions openstack_dashboard/dashboards/admin/domains/panel.py
Expand Up @@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

import horizon
Expand All @@ -28,10 +27,5 @@ class Domains(horizon.Panel):
slug = 'domains'


MULTIDOMAIN_SUPPORT = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)


if MULTIDOMAIN_SUPPORT and IDENTITY_VERSIONS.active >= 3:
if IDENTITY_VERSIONS.active >= 3:
dashboard.Admin.register(Domains)
13 changes: 13 additions & 0 deletions openstack_dashboard/dashboards/admin/domains/tables.py
Expand Up @@ -16,6 +16,7 @@

import logging

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from keystoneclient.exceptions import ClientException
Expand Down Expand Up @@ -77,6 +78,12 @@ def delete(self, request, obj_id):


class DomainFilterAction(tables.FilterAction):
def allowed(self, request, datum):
multidomain_support = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)
return multidomain_support

def filter(self, table, domains, filter_string):
""" Naive case-insensitive search """
q = filter_string.lower()
Expand All @@ -96,6 +103,12 @@ class SetDomainContext(tables.Action):
preempt = True

def allowed(self, request, datum):
multidomain_support = getattr(settings,
'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT',
False)
if not multidomain_support:
return False

ctx = request.session.get("domain_context", None)
if ctx and datum.id == ctx:
return False
Expand Down

0 comments on commit 160ea12

Please sign in to comment.