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
This commit is contained in:
Dean Troyer 2014-08-27 17:19:49 -05:00
parent 7a8c9a7a8a
commit e19216e282

View File

@ -23,6 +23,7 @@ from cliff import command
from cliff import lister
from cliff import show
from keystoneclient.openstack.common.apiclient import exceptions as ksc_exc
from novaclient.v1_1 import security_group_rules
from openstackclient.common import parseractions
from openstackclient.common import utils
@ -150,8 +151,13 @@ class ListSecurityGroup(lister.Lister):
search = {'all_tenants': parsed_args.all_projects}
data = compute_client.security_groups.list(search_opts=search)
projects = self.app.client_manager.identity.projects.list()
project_hash = {}
try:
projects = self.app.client_manager.identity.projects.list()
except ksc_exc.Forbidden:
# This fails when the user is not an admin, just move along
pass
else:
for project in projects:
project_hash[project.id] = project