add list users

This commit is contained in:
termie 2012-01-04 17:13:23 -08:00
parent 46943c5f41
commit 5c89972ffe
3 changed files with 21 additions and 1 deletions

View File

@ -63,6 +63,9 @@ class KvsIdentity(object):
role_ref = self.db.get('role-%s' % role_id)
return role_ref
def list_users(self):
return self.db.get('user_list', [])
# These should probably be part of the high-level API
def add_user_to_tenant(self, tenant_id, user_id):
user_ref = self.get_user(user_id)
@ -112,6 +115,9 @@ class KvsIdentity(object):
def create_user(self, id, user):
self.db.set('user-%s' % id, user)
self.db.set('user_name-%s' % user['name'], user)
user_list = set(self.db.get('user_list', []))
user_list.add(id)
self.db.set('user_list', list(user_list))
return user
def update_user(self, id, user):
@ -126,6 +132,9 @@ class KvsIdentity(object):
old_user = self.db.get('user-%s' % id)
self.db.delete('user_name-%s' % old_user['name'])
self.db.delete('user-%s' % id)
user_list = set(self.db.get('user_list', []))
user_list.remove(id)
self.db.set('user_list', list(user_list))
return None
def create_tenant(self, id, tenant):

View File

@ -37,6 +37,11 @@ class Manager(object):
def get_role(self, context, role_id):
return self.driver.get_role(role_id)
# NOTE(termie): i think it will probably be a bad move in the end to try to
# list all users
def list_users(self, context):
return self.driver.list_users()
# These should probably be the high-level API calls
def add_user_to_tenant(self, context, user_id, tenant_id):
self.driver.add_user_to_tenant(user_id, tenant_id)

View File

@ -587,6 +587,13 @@ class KeystoneUserController(service.BaseApplication):
raise exc.HTTPNotFound()
return {'user': user_ref}
def get_users(self, context):
# NOTE(termie): i can't imagine that this really wants all the data
# about every single user in the system...
self.assert_admin(context)
user_list = self.identity_api.list_users(context)
return {'users': [{'id': x} for x in user_list]}
# CRUD extension
def create_user(self, context, user):
self.assert_admin(context)
@ -630,7 +637,6 @@ class KeystoneUserController(service.BaseApplication):
return self.update_user(context, user_id, user)
class KeystoneRoleController(service.BaseApplication):
def __init__(self, options):
self.options = options