feat: get machine state

This commit is contained in:
Alberto Lerda 2023-02-15 09:55:32 +01:00
parent 8eb9e416ca
commit e07b9e2b9d
2 changed files with 9 additions and 2 deletions

2
example/get_state.py Normal file
View File

@ -0,0 +1,2 @@
#/bin/bash
curl localhost:8000/state/urn:fabaccess:resource:Another

View File

@ -89,6 +89,7 @@ async def command(cmd: Command):
if session == None: if session == None:
raise HTTPException(status_code=500, detail="Fabaccess not available") raise HTTPException(status_code=500, detail="Fabaccess not available")
info = session.machineSystem.info info = session.machineSystem.info
print(cmd.service)
ma = await info.getMachineURN(cmd.service).a_wait() ma = await info.getMachineURN(cmd.service).a_wait()
try: try:
@ -113,6 +114,10 @@ async def state(urn: str):
if session == None: if session == None:
raise HTTPException(status_code=500, detail="Fabaccess not available") raise HTTPException(status_code=500, detail="Fabaccess not available")
info = session.machineSystem.info info = session.machineSystem.info
ma = await info.getMachineURN(cmd.service).a_wait() print(urn)
ma = await info.getMachineURN(urn).a_wait()
return {"state": ma.state} if ma.just:
return {"state": str(ma.just.state)}
else:
raise HTTPException(status_code=500, detail="Fabaccess not available")