dbd1b6e2a302f9806e55833dc9d6ae793374306a
[osm/N2VC.git] / leadership.py
1 """
2 This example:
3
4 1. Connects to the current model.
5 2. Prints out leadership status for all deployed units in the model.
6 3. Cleanly disconnects.
7
8 """
9 import asyncio
10
11 from juju.model import Model
12 from juju import loop
13
14 async def report_leadership():
15 model = Model()
16 await model.connect()
17
18 print("Leadership: ")
19 for app in model.applications.values():
20 for unit in app.units:
21 print("{}: {}".format(
22 unit.name, await unit.is_leader_from_status()))
23
24 await model.disconnect()
25
26
27 if __name__ == '__main__':
28 loop.run(report_leadership())