4 1. Connects to the current model.
5 2. Prints out leadership status for all deployed units in the model.
6 3. Cleanly disconnects.
11 from juju
.model
import Model
13 async def report_leadership():
15 await model
.connect_current()
18 for app
in model
.applications
.values():
19 for unit
in app
.units
:
20 print("{}: {}".format(
21 unit
.name
, await unit
.is_leader_from_status()))
23 await model
.disconnect()
25 loop
= asyncio
.get_event_loop()
26 loop
.run_until_complete(report_leadership())