Squashed 'modules/libjuju/' content from commit c50c361
[osm/N2VC.git] / 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 asyncio
12 import logging
13
14 from juju.controller import Controller
15 from juju import loop
16
17
18 async def main():
19 controller = Controller()
20 await controller.connect_current()
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())