New N2VC interface + updated libjuju
[osm/N2VC.git] / modules / libjuju / examples / future.py
1 """
2 This example doesn't work - it demonstrates features that don't exist yet.
3
4 """
5 import asyncio
6 import logging
7
8 from juju.model import Model
9 from juju import loop
10
11
12 async def main():
13 model = Model()
14 await model.connect()
15 await model.reset(force=True)
16
17 goal_state = Model.from_yaml('bundle-like-thing')
18 ubuntu_app = await model.deploy(
19 'ubuntu-0',
20 application_name='ubuntu',
21 series='trusty',
22 channel='stable',
23 )
24 ubuntu_app.on_unit_added(callback=lambda unit: True)
25
26 await model.deploy(
27 'nrpe-11',
28 application_name='nrpe',
29 series='trusty',
30 channel='stable',
31 num_units=0,
32 )
33 await model.add_relation(
34 'ubuntu',
35 'nrpe',
36 )
37
38 result, ok = await model.block_until(
39 lambda: model.matches(goal_state),
40 timeout=600
41 )
42
43
44 if __name__ == '__main__':
45 logging.basicConfig(level=logging.DEBUG)
46 ws_logger = logging.getLogger('websockets.protocol')
47 ws_logger.setLevel(logging.INFO)
48 loop.run(main())