-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathdeploy_bundle_with_trust.py
More file actions
48 lines (37 loc) · 1.18 KB
/
deploy_bundle_with_trust.py
File metadata and controls
48 lines (37 loc) · 1.18 KB
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
# 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 bundle with trust and waits until it reports itself active
3. Destroys the units and applications
"""
import asyncio
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 trusted bundle application ubuntu")
applications = await model.deploy(
"ch:aws-integrator",
trust=True,
)
print("Waiting for active")
await model.block_until(
lambda: all(
unit.workload_status == "active"
for application in applications
for unit in application.units
)
)
print("Successfully deployed!")
print("Removing bundle")
for application in applications:
await application.remove()
finally:
print("Disconnecting from model")
await model.disconnect()
if __name__ == "__main__":
asyncio.run(main())