-
Notifications
You must be signed in to change notification settings - Fork 93
/
deploy_constraints.py
39 lines (30 loc) · 1.02 KB
/
deploy_constraints.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
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.
"""
This example:
1. Connects to the current controller
2. Adds a model to the controller
3. Attempts to deploy a charm with constraints
"""
from juju import jasyncio
from juju.controller import Controller
async def main():
controller = Controller()
await controller.connect()
try:
model = await controller.add_model("test-model")
application = await model.deploy("ch:ubuntu",
constraints={"arch": "amd64"})
print('Waiting for active')
await model.block_until(
lambda: all(unit.workload_status == 'active'
for unit in application.units))
print("Successfully deployed!")
print('Removing bundle')
await application.remove()
finally:
print('Disconnecting from controller')
await controller.disconnect()
print("Success")
if __name__ == '__main__':
jasyncio.run(main())