X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fexamples%2Fcontroller.py;fp=modules%2Flibjuju%2Fexamples%2Fcontroller.py;h=6002f683632fa3655d40887717a8eb7cfce70e9f;hp=0000000000000000000000000000000000000000;hb=68858c1915122c2dbc8999a5cd3229694abf5f3a;hpb=032a71b2a6692b8b4e30f629a1f906d246f06736 diff --git a/modules/libjuju/examples/controller.py b/modules/libjuju/examples/controller.py new file mode 100644 index 0000000..6002f68 --- /dev/null +++ b/modules/libjuju/examples/controller.py @@ -0,0 +1,41 @@ +""" +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 asyncio +import logging + +from juju.controller import Controller +from juju import loop + + +async def main(): + controller = Controller() + await controller.connect_current() + model = await controller.add_model( + 'my-test-model', + 'aws', + 'aws-tim', + ) + await model.deploy( + 'ubuntu-0', + application_name='ubuntu', + series='trusty', + 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) + loop.run(main())