-
Notifications
You must be signed in to change notification settings - Fork 93
/
controller.py
44 lines (36 loc) · 1.03 KB
/
controller.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
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.
"""
This example:
1. Connects to current controller.
2. Creates a new model.
3. Deploys an application on the new model.
4. Disconnects from the model
5. Destroys the model
"""
import logging
from juju.controller import Controller
from juju import jasyncio
async def main():
controller = Controller()
# connect to current controller with current user, per Juju CLI
await controller.connect()
model = await controller.add_model(
'my-test-model',
'aws',
'aws-tim',
)
await model.deploy(
'ubuntu',
application_name='ubuntu',
series='focal',
channel='stable',
)
await model.disconnect()
await controller.destroy_model(model.info.uuid)
await controller.disconnect()
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger('websockets.protocol')
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())