-
Notifications
You must be signed in to change notification settings - Fork 93
/
deploy.py
42 lines (32 loc) · 983 Bytes
/
deploy.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
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.
"""
This example:
1. Connects to the current model
2. Deploy a charm and waits until it reports itself active
3. Destroys the unit and application
"""
from juju import jasyncio
from juju.model import Model
async def main():
model = Model()
print('Connecting to model')
# connect to current model with current user, per Juju CLI
await model.connect()
try:
print('Deploying ubuntu')
application = await model.deploy(
'ch:ubuntu',
application_name='ubuntu',
series='trusty',
channel='stable',
)
print('Waiting for active')
await model.wait_for_idle(status='active')
print('Removing ubuntu')
await application.remove()
finally:
print('Disconnecting from model')
await model.disconnect()
if __name__ == '__main__':
jasyncio.run(main())