Update exceptions
[osm/N2VC.git] / modules / libjuju / examples / controller.py
1 """
2 This example:
3
4 1. Connects to current controller.
5 2. Creates a new model.
6 3. Deploys an application on the new model.
7 4. Disconnects from the model
8 5. Destroys the model
9
10 """
11 import logging
12
13 from juju.controller import Controller
14 from juju import loop
15
16
17 async def main():
18 controller = Controller()
19 # connect to current controller with current user, per Juju CLI
20 await controller.connect()
21 model = await controller.add_model(
22 'my-test-model',
23 'aws',
24 'aws-tim',
25 )
26 await model.deploy(
27 'ubuntu-0',
28 application_name='ubuntu',
29 series='trusty',
30 channel='stable',
31 )
32 await model.disconnect()
33 await controller.destroy_model(model.info.uuid)
34 await controller.disconnect()
35
36
37 if __name__ == '__main__':
38 logging.basicConfig(level=logging.DEBUG)
39 ws_logger = logging.getLogger('websockets.protocol')
40 ws_logger.setLevel(logging.INFO)
41 loop.run(main())