From e19216e2824c04870f9fe44ab5b864814538694b Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 27 Aug 2014 17:19:49 -0500 Subject: [PATCH] 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 --- openstackclient/compute/v2/security_group.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index 0ba55c9834..cd33085707 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -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,10 +151,15 @@ 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 = {} - for project in projects: - project_hash[project.id] = project + 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 return (column_headers, (utils.get_item_properties(