blob: 47eb999b528e5cb281f092b3b2f0458986889af1 [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example:
3
41. Connects to the current model
52. Watches the model and prints all changes
63. Runs forever (kill with Ctrl-C)
7
8"""
9import asyncio
10
11from juju.model import Model
12from juju import loop
13
14
15async def on_model_change(delta, old, new, model):
16 print(delta.entity, delta.type, delta.data)
17 print(old)
18 print(new)
19 print(model)
20
21
22async def watch_model():
23 model = Model()
24 await model.connect_current()
25
26 model.add_observer(on_model_change)
27
28
29if __name__ == '__main__':
30 # Run loop until the process is manually stopped (watch_model will loop
31 # forever).
32 loop.run(watch_model())