Skip to content

Commit

Permalink
Update of API
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav committed Nov 25, 2024
1 parent b2996aa commit 3f220e0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions mupifDB/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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'
Expand All @@ -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)


Expand Down

0 comments on commit 3f220e0

Please sign in to comment.