mirror of
https://gitlab.com/fabinfra/fabaccess/pyfabapi.git
synced 2025-03-12 14:51:42 +01:00
23 lines
763 B
Python
23 lines
763 B
Python
|
import asyncio
|
||
|
import fabapi
|
||
|
import fabapi.user_system
|
||
|
|
||
|
async def main():
|
||
|
session = await fabapi.connect("localhost", 59661, "Testuser", "secret")
|
||
|
info = session.machineSystem.info
|
||
|
ma = await info.getMachineURN("urn:fabaccess:resource:Another").a_wait()
|
||
|
# ma.just isn't set if the above selected resource doesn't exist
|
||
|
if ma.just:
|
||
|
await ma.just.use.use().a_wait()
|
||
|
# Do whatever
|
||
|
|
||
|
# To give the resource back we have to re-query the changed state
|
||
|
ma = await info.getMachineURN("urn:fabaccess:resource:Another").a_wait()
|
||
|
await ma.just.inuse.giveBack().a_wait()
|
||
|
else:
|
||
|
print("No such resource!")
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
loop = asyncio.get_event_loop()
|
||
|
loop.run_until_complete(main())
|