-
Notifications
You must be signed in to change notification settings - Fork 93
/
future.py
50 lines (40 loc) · 1.14 KB
/
future.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.
"""
This example doesn't work - it demonstrates features that don't exist yet.
"""
import logging
from juju.model import Model
from juju import jasyncio
async def main():
model = Model()
# connect to current model with current user, per Juju CLI
await model.connect()
goal_state = Model.from_yaml('bundle-like-thing')
ubuntu_app = await model.deploy(
'ch:ubuntu',
application_name='ubuntu',
series='trusty',
channel='stable',
)
ubuntu_app.on_unit_added(callback=lambda unit: True)
await model.deploy(
'ch:nrpe',
application_name='nrpe',
series='trusty',
channel='stable',
num_units=0,
)
await model.relate(
'ubuntu',
'nrpe',
)
result, ok = await model.block_until(
lambda: model.matches(goal_state),
timeout=600
)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger('websockets.protocol')
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())