X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Fnbi.py;h=fa414f053384983fa4b1c786697f9f1bd27c8846;hb=a04d59bd184959b9ea88baccea05274b8851d3f5;hp=80548ce571c85c5e364750deb69cc1b98de71f0a;hpb=43eac1e0ea322648e9ca00fcf98b2bdfd6a35871;p=osm%2FNBI.git diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 80548ce5..fa414f05 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -115,8 +115,6 @@ URL: /osm GET POST / O O O /k8sclusters O O / O O O - /paas O5 O5 - / O5 O5 O5 /k8srepos O O / O O /osmrepos O O @@ -290,14 +288,6 @@ valid_url_methods = { "ROLE_PERMISSION": "vca:id:", }, }, - "paas": { - "METHODS": ("GET", "POST"), - "ROLE_PERMISSION": "paas:", - "": { - "METHODS": ("GET", "DELETE", "PATCH"), - "ROLE_PERMISSION": "paas:id:", - }, - }, "k8srepos": { "METHODS": ("GET", "POST"), "ROLE_PERMISSION": "k8srepos:", @@ -669,6 +659,7 @@ class Server(object): self.engine = Engine(self.authenticator) def _format_in(self, kwargs): + error_text = "" # error_text must be initialized outside try try: indata = None if cherrypy.request.body.length: @@ -1010,7 +1001,6 @@ class Server(object): ) return self._format_out("Alarm updated") except Exception as e: - cherrypy.response.status = e.http_code.value if isinstance( e, ( @@ -1071,7 +1061,7 @@ class Server(object): outdata = token_info = self.authenticator.new_token( token_info, indata, cherrypy.request.remote ) - cherrypy.session["Authorization"] = outdata["_id"] + cherrypy.session["Authorization"] = outdata["_id"] # pylint: disable=E1101 self._set_location_header("admin", "v1", "tokens", outdata["_id"]) # for logging self._format_login(token_info) @@ -1094,7 +1084,7 @@ class Server(object): token_id = token_info["_id"] outdata = self.authenticator.del_token(token_id) token_info = None - cherrypy.session["Authorization"] = "logout" + cherrypy.session["Authorization"] = "logout" # pylint: disable=E1101 # cherrypy.response.cookie["Authorization"] = token_id # cherrypy.response.cookie["Authorization"]['expires'] = 0 else: @@ -1122,7 +1112,8 @@ class Server(object): elif args and args[0] == "init": try: # self.engine.load_dbase(cherrypy.request.app.config) - self.engine.create_admin() + pid = self.authenticator.create_admin_project() + self.authenticator.create_admin_user(pid) return "Done. User 'admin', password 'admin' created" except Exception: cherrypy.response.status = HTTPStatus.FORBIDDEN.value @@ -1200,10 +1191,12 @@ class Server(object): + " headers: {}\n".format(cherrypy.request.headers) + " path_info: {}\n".format(cherrypy.request.path_info) + " query_string: {}\n".format(cherrypy.request.query_string) - + " session: {}\n".format(cherrypy.session) + + " session: {}\n".format(cherrypy.session) # pylint: disable=E1101 + " cookie: {}\n".format(cherrypy.request.cookie) + " method: {}\n".format(cherrypy.request.method) - + " session: {}\n".format(cherrypy.session.get("fieldname")) + + " session: {}\n".format( + cherrypy.session.get("fieldname") # pylint: disable=E1101 + ) + " body:\n" ) return_text += " length: {}\n".format(cherrypy.request.body.length) @@ -1796,7 +1789,6 @@ class Server(object): self.engine.db.del_list( rollback_item["topic"], rollback_item["filter"], - fail_on_empty=False, ) else: self.engine.db.del_one( @@ -1872,7 +1864,9 @@ def _start_service(): except ValueError as e: cherrypy.log.error("Ignoring environ '{}': " + str(e)) except Exception as e: - cherrypy.log.warn("skipping environ '{}' on exception '{}'".format(k, e)) + cherrypy.log( + "WARNING: skipping environ '{}' on exception '{}'".format(k, e) + ) if update_dict: cherrypy.config.update(update_dict)