Adding filter to ProjectTopicAuth
[osm/NBI.git] / osm_nbi / authconn_keystone.py
index e917306..b0cab0c 100644 (file)
@@ -347,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:
@@ -360,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")