Skip to content

Commit e19216e

Browse files
author
Dean Troyer
committed
Fix security group list for non-admin
Non-admin users couldn't list security groups due to the project lookup failure. That shouldn't stop the listing. Change-Id: I27f6ff4975b35d1de1c852c8d4e830b83c7dec75
1 parent 7a8c9a7 commit e19216e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎openstackclient/compute/v2/security_group.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from cliff import lister
2424
from cliff import show
2525

26+
from keystoneclient.openstack.common.apiclient import exceptions as ksc_exc
2627
from novaclient.v1_1 import security_group_rules
2728
from openstackclient.common import parseractions
2829
from openstackclient.common import utils
@@ -150,10 +151,15 @@ def _get_project(project_id):
150151
search = {'all_tenants': parsed_args.all_projects}
151152
data = compute_client.security_groups.list(search_opts=search)
152153

153-
projects = self.app.client_manager.identity.projects.list()
154154
project_hash = {}
155-
for project in projects:
156-
project_hash[project.id] = project
155+
try:
156+
projects = self.app.client_manager.identity.projects.list()
157+
except ksc_exc.Forbidden:
158+
# This fails when the user is not an admin, just move along
159+
pass
160+
else:
161+
for project in projects:
162+
project_hash[project.id] = project
157163

158164
return (column_headers,
159165
(utils.get_item_properties(

0 commit comments

Comments
 (0)