From 3f220e07049f78c1bf5f1e853f285f685b3d855b Mon Sep 17 00:00:00 2001 From: Stanislav <“sulcstanda@seznam.cz”> Date: Mon, 25 Nov 2024 01:58:14 +0100 Subject: [PATCH] Update of API --- mupifDB/api/main.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/mupifDB/api/main.py b/mupifDB/api/main.py index a03da10..4e9451a 100644 --- a/mupifDB/api/main.py +++ b/mupifDB/api/main.py @@ -44,7 +44,8 @@ from rich.pretty import pprint # shorthands for common exceptions -def NotFoundError(detail): return HTTPException(status_code=404,detail=detail) +def NotFoundError(detail): + return HTTPException(status_code=404, detail=detail) from mupifDB import models @@ -114,7 +115,8 @@ async def validation_exception_handler(request: fastapi.Request, exc: fastapi.ex # when imported at readthedocs, don't try to connect to the DB (no DB running there) if 'MUPIFDB_DRY_RUN' not in os.environ and not cmdline_opts.export_openapi: edm.initializeEdm(client) - else: log.info('MUPIFDB_DRY_RUN / --generate-openapi active, not initializing EDM DB connection.') + else: + log.info('MUPIFDB_DRY_RUN / --generate-openapi active, not initializing EDM DB connection.') app.include_router(edm.dms3.router) @@ -640,7 +642,7 @@ def set_scheduler_statistics(data: M_ModifyStatistics): def get_status2(): ns = None try: - ns = mupif.pyroutil.connectNameserver() + ns = mp.pyroutil.connectNameserver() nameserverStatus = 'OK' except: nameserverStatus = 'Failed' @@ -654,32 +656,36 @@ def get_status2(): schedulerStatus = 'OK' except Exception as e: print(str(e)) - + # get DMS status if (client): DMSStatus = 'OK' else: DMSStatus = 'Failed' - + return {'nameserver': nameserverStatus, 'dms': DMSStatus, 'scheduler': schedulerStatus, 'name':os.environ["MUPIF_VPN_NAME"]} + @app.get("/scheduler-status2/", tags=["Stats"]) def get_scheduler_status2(): - ns = mupif.pyroutil.connectNameserver(); + ns = mp.pyroutil.connectNameserver() return mp.monitor.schedulerInfo(ns) + @app.get("/ns-status2/", tags=["Stats"]) def get_ns_status2(): - ns = mupif.pyroutil.connectNameserver(); + ns = mp.pyroutil.connectNameserver() return mp.monitor.nsInfo(ns) + @app.get("/vpn-status2/", tags=["Stats"]) def get_vpn_status2(): - return mupif.monitor.vpnInfo(hidePriv=False) + return mp.monitor.vpnInfo(hidePriv=False) + @app.get("/jobmans-status2/", tags=["Stats"]) def get_jobmans_status2(): - ns = mupif.pyroutil.connectNameserver(); + ns = mp.pyroutil.connectNameserver() return mp.monitor.jobmanInfo(ns)