Squashed 'modules/libjuju/' content from commit c50c361
git-subtree-dir: modules/libjuju
git-subtree-split: c50c361a8b9a3bbf1a33f5659e492b481f065cd2
diff --git a/examples/leadership.py b/examples/leadership.py
new file mode 100644
index 0000000..b231003
--- /dev/null
+++ b/examples/leadership.py
@@ -0,0 +1,28 @@
+"""
+This example:
+
+1. Connects to the current model.
+2. Prints out leadership status for all deployed units in the model.
+3. Cleanly disconnects.
+
+"""
+import asyncio
+
+from juju.model import Model
+from juju import loop
+
+async def report_leadership():
+ model = Model()
+ await model.connect_current()
+
+ print("Leadership: ")
+ for app in model.applications.values():
+ for unit in app.units:
+ print("{}: {}".format(
+ unit.name, await unit.is_leader_from_status()))
+
+ await model.disconnect()
+
+
+if __name__ == '__main__':
+ loop.run(report_leadership())