More logging in pillar.api.service.do_badger()

This commit is contained in:
2017-05-10 11:15:29 +02:00
parent c854ccbb4b
commit c77a6b9d21

View File

@@ -89,12 +89,17 @@ def do_badger(action: str, role: str, *, user_email: str='', user_id: bson.Objec
""" """
if action not in {'grant', 'revoke'}: if action not in {'grant', 'revoke'}:
log.error('do_badger(%r, %r, %r, %r): action %r not supported.',
action, role, user_email, user_id, action)
raise wz_exceptions.BadRequest('Action %r not supported' % action) raise wz_exceptions.BadRequest('Action %r not supported' % action)
if not user_email and user_id is None: if not user_email and user_id is None:
log.error('do_badger(%r, %r, %r, %r): neither email nor user_id given.',
action, role, user_email, user_id)
raise wz_exceptions.BadRequest('User email not given') raise wz_exceptions.BadRequest('User email not given')
if not role: if not role:
log.error('do_badger(%r, %r, %r, %r): no role given.', action, role, user_email, user_id)
raise wz_exceptions.BadRequest('Role not given') raise wz_exceptions.BadRequest('Role not given')
users_coll = current_app.data.driver.db['users'] users_coll = current_app.data.driver.db['users']
@@ -123,6 +128,8 @@ def do_badger(action: str, role: str, *, user_email: str='', user_id: bson.Objec
if groups is not None: if groups is not None:
updates['groups'] = list(groups) updates['groups'] = list(groups)
log.debug('badger(%s, %s, user_email=%s, user_id=%s): applying updates %r',
action, role, user_email, user_id, updates)
users_coll.update_one({'_id': db_user['_id']}, users_coll.update_one({'_id': db_user['_id']},
{'$set': updates}) {'$set': updates})