mirror of
https://github.com/interfacerproject/zenflows-fabaccess.git
synced 2025-03-12 15:01:44 +01:00
feat: get machine state
This commit is contained in:
parent
8eb9e416ca
commit
e07b9e2b9d
2
example/get_state.py
Normal file
2
example/get_state.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#/bin/bash
|
||||||
|
curl localhost:8000/state/urn:fabaccess:resource:Another
|
9
main.py
9
main.py
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user