blob: 01803255494c8fb594e584251a20a5ee82f991ac [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example doesn't work - it demonstrates features that don't exist yet.
3
4"""
5import asyncio
6import logging
7
8from juju.model import Model
9from juju import loop
10
11
12async def main():
13 model = Model()
14 await model.connect_current()
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
44if __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())