From e07b9e2b9d8fb77faba0bdf21302f78de7d9a065 Mon Sep 17 00:00:00 2001 From: Alberto Lerda Date: Wed, 15 Feb 2023 09:55:32 +0100 Subject: [PATCH] feat: get machine state --- example/get_state.py | 2 ++ main.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 example/get_state.py diff --git a/example/get_state.py b/example/get_state.py new file mode 100644 index 0000000..334f366 --- /dev/null +++ b/example/get_state.py @@ -0,0 +1,2 @@ +#/bin/bash +curl localhost:8000/state/urn:fabaccess:resource:Another diff --git a/main.py b/main.py index 4c91da0..f9bac51 100644 --- a/main.py +++ b/main.py @@ -89,6 +89,7 @@ async def command(cmd: Command): if session == None: raise HTTPException(status_code=500, detail="Fabaccess not available") info = session.machineSystem.info + print(cmd.service) ma = await info.getMachineURN(cmd.service).a_wait() try: @@ -113,6 +114,10 @@ async def state(urn: str): if session == None: raise HTTPException(status_code=500, detail="Fabaccess not available") 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")