blob: 5e974cfc95ef15c60d50e86a05b7f217d757884b [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"""
Adam Israeldcdf82b2017-08-15 15:26:43 -04005import logging
6
7from juju.model import Model
8from juju import loop
9
10
11async def main():
12 model = Model()
Adam Israelb0943662018-08-02 15:32:00 -040013 # connect to current model with current user, per Juju CLI
Adam Israelc3e6c2e2018-03-01 09:31:50 -050014 await model.connect()
Adam Israeldcdf82b2017-08-15 15:26:43 -040015
16 goal_state = Model.from_yaml('bundle-like-thing')
17 ubuntu_app = await model.deploy(
18 'ubuntu-0',
19 application_name='ubuntu',
20 series='trusty',
21 channel='stable',
22 )
23 ubuntu_app.on_unit_added(callback=lambda unit: True)
24
25 await model.deploy(
26 'nrpe-11',
27 application_name='nrpe',
28 series='trusty',
29 channel='stable',
30 num_units=0,
31 )
32 await model.add_relation(
33 'ubuntu',
34 'nrpe',
35 )
36
37 result, ok = await model.block_until(
38 lambda: model.matches(goal_state),
39 timeout=600
40 )
41
42
43if __name__ == '__main__':
44 logging.basicConfig(level=logging.DEBUG)
45 ws_logger = logging.getLogger('websockets.protocol')
46 ws_logger.setLevel(logging.INFO)
47 loop.run(main())