mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #26277 from rallytime/fix-26240
Handle exception when user is not found in keystone.user_get
This commit is contained in:
commit
bcca1b4c5a
1 changed files with 13 additions and 1 deletions
|
@ -49,6 +49,10 @@ Module for handling openstack keystone calls.
|
|||
salt '*' keystone.tenant_list profile=openstack1
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
|
||||
# Import third party libs
|
||||
HAS_KEYSTONE = False
|
||||
try:
|
||||
|
@ -58,6 +62,8 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -699,7 +705,13 @@ def user_get(user_id=None, name=None, profile=None, **connection_args):
|
|||
break
|
||||
if not user_id:
|
||||
return {'Error': 'Unable to resolve user id'}
|
||||
user = kstone.users.get(user_id)
|
||||
try:
|
||||
user = kstone.users.get(user_id)
|
||||
except keystoneclient.exceptions.NotFound:
|
||||
msg = 'Could not find user \'{0}\''.format(user_id)
|
||||
log.error(msg)
|
||||
return {'Error': msg}
|
||||
|
||||
ret[user.name] = {'id': user.id,
|
||||
'name': user.name,
|
||||
'email': user.email,
|
||||
|
|
Loading…
Add table
Reference in a new issue