blob: c93981a58d9f56a843029d52c82e7e47a12bd88d [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()
Adam Israelc3e6c2e2018-03-01 09:31:50 -050014 await model.connect()
Adam Israeldcdf82b2017-08-15 15:26:43 -040015 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())