blob: dbd1b6e2a302f9806e55833dc9d6ae793374306a [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example:
3
41. Connects to the current model.
52. Prints out leadership status for all deployed units in the model.
63. Cleanly disconnects.
7
8"""
9import asyncio
10
11from juju.model import Model
12from juju import loop
13
14async def report_leadership():
15 model = Model()
Adam Israelc3e6c2e2018-03-01 09:31:50 -050016 await model.connect()
Adam Israeldcdf82b2017-08-15 15:26:43 -040017
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
27if __name__ == '__main__':
28 loop.run(report_leadership())