From 12eac3c4ea2f1c35f746543922b6d8e02e25f480 Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 19 Mar 2020 23:22:08 +0000 Subject: [PATCH] get user/project domains with admin/v1/domains Change-Id: I64c8920eb76d24c517c8e289382de4fa97931e9c Signed-off-by: tierno --- osm_nbi/nbi.py | 21 ++++++++++++++++++++- osm_nbi/resources_to_operations.yml | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 2d2d635..bd0f2a1 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -266,7 +266,9 @@ valid_url_methods = { "ROLE_PERMISSION": "k8srepos:id:" } }, - + "domains": {"METHODS": ("GET", ), + "ROLE_PERMISSION": "domains:", + }, } }, "pdu": { @@ -657,6 +659,21 @@ class Server(object): } return self._format_out(problem_details, None) + def domain(self): + try: + domains = { + "user_domain_name": cherrypy.tree.apps['/osm'].config["authentication"].get("user_domain_name"), + "project_domain_name": cherrypy.tree.apps['/osm'].config["authentication"].get("project_domain_name")} + return self._format_out(domains) + except NbiException as e: + cherrypy.response.status = e.http_code.value + problem_details = { + "code": e.http_code.name, + "status": e.http_code.value, + "detail": str(e), + } + return self._format_out(problem_details, None) + @staticmethod def _format_login(token_info): """ @@ -975,6 +992,8 @@ class Server(object): if main_topic == "admin" and topic == "tokens": return self.token(method, _id, kwargs) token_info = self.authenticator.authorize(role_permission, query_string_operations, _id) + if main_topic == "admin" and topic == "domains": + return self.domain() engine_session = self._manage_admin_query(token_info, kwargs, method, _id) indata = self._format_in(kwargs) engine_topic = topic diff --git a/osm_nbi/resources_to_operations.yml b/osm_nbi/resources_to_operations.yml index 4f1d8dc..7520420 100644 --- a/osm_nbi/resources_to_operations.yml +++ b/osm_nbi/resources_to_operations.yml @@ -175,6 +175,8 @@ resources_to_operations: "PATCH /admin/v1/users/": "users:id:patch" + "GET /admin/v1/domains": "domains:get" + ################################################################################ #################################### Projects ################################## ################################################################################ -- 2.17.1