X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fauthconn_keystone.py;h=b0cab0c7af6b1139583412b6fbcd45d792c31473;hp=54442c8c9d617f699def4ecf91dea056254cb3da;hb=fa54cd99ee561e02ef95128cd3d25074aa1dbe54;hpb=5c01e193a17fcf730406e39fe7d019e1dee5c64d diff --git a/osm_nbi/authconn_keystone.py b/osm_nbi/authconn_keystone.py index 54442c8..b0cab0c 100644 --- a/osm_nbi/authconn_keystone.py +++ b/osm_nbi/authconn_keystone.py @@ -247,10 +247,11 @@ class AuthconnKeystone(Authconn): self.logger.exception("Error during user deletion using keystone") raise AuthconnOperationException("Error during user deletion using Keystone") - def get_user_list(self): + def get_user_list(self, filter_q={}): """ Get user list. + :param filter_q: dictionary to filter user list. :return: returns a list of users. """ try: @@ -260,6 +261,14 @@ class AuthconnKeystone(Authconn): "_id": user.id } for user in users if user.name != self.admin_username] + allowed_fields = ["_id", "username"] + for key in filter_q.keys(): + if key not in allowed_fields: + continue + + users = [user for user in users + if filter_q[key] == user[key]] + for user in users: projects = self.keystone.projects.list(user=user["_id"]) projects = [{ @@ -338,10 +347,11 @@ class AuthconnKeystone(Authconn): self.logger.exception("Error during role deletion using keystone") raise AuthconnOperationException("Error during role deletion using Keystone") - def get_project_list(self): + def get_project_list(self, filter_q={}): """ Get all the projects. + :param filter_q: dictionary to filter project list. :return: list of projects """ try: @@ -351,6 +361,14 @@ class AuthconnKeystone(Authconn): "_id": project.id } for project in projects if project.name != self.admin_project] + allowed_fields = ["_id", "name"] + for key in filter_q.keys(): + if key not in allowed_fields: + continue + + projects = [project for project in projects + if filter_q[key] == project[key]] + return projects except ClientException: self.logger.exception("Error during user project listing using keystone")