Revert "Remove vendored libjuju"
This reverts commit 9d18c22a0dc9e295adda50601fc5e2f45d2c9b8a.
Change-Id: I7dbf291ccd750c5f836ff80c642be492434ab3ac
Signed-off-by: Adam Israel <adam.israel@canonical.com>
diff --git a/modules/libjuju/examples/livemodel.py b/modules/libjuju/examples/livemodel.py
new file mode 100644
index 0000000..1b10ac9
--- /dev/null
+++ b/modules/libjuju/examples/livemodel.py
@@ -0,0 +1,31 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Watches the model and prints all changes
+3. Runs forever (kill with Ctrl-C)
+
+"""
+from juju.model import Model
+from juju import loop
+
+
+async def on_model_change(delta, old, new, model):
+ print(delta.entity, delta.type, delta.data)
+ print(old)
+ print(new)
+ print(model)
+
+
+async def watch_model():
+ model = Model()
+ # connect to current model with current user, per Juju CLI
+ await model.connect()
+
+ model.add_observer(on_model_change)
+
+
+if __name__ == '__main__':
+ # Run loop until the process is manually stopped (watch_model will loop
+ # forever).
+ loop.run(watch_model())