X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fexamples%2Ffuture.py;fp=modules%2Flibjuju%2Fexamples%2Ffuture.py;h=01803255494c8fb594e584251a20a5ee82f991ac;hp=0000000000000000000000000000000000000000;hb=68858c1915122c2dbc8999a5cd3229694abf5f3a;hpb=032a71b2a6692b8b4e30f629a1f906d246f06736 diff --git a/modules/libjuju/examples/future.py b/modules/libjuju/examples/future.py new file mode 100644 index 0000000..0180325 --- /dev/null +++ b/modules/libjuju/examples/future.py @@ -0,0 +1,48 @@ +""" +This example doesn't work - it demonstrates features that don't exist yet. + +""" +import asyncio +import logging + +from juju.model import Model +from juju import loop + + +async def main(): + model = Model() + await model.connect_current() + await model.reset(force=True) + + goal_state = Model.from_yaml('bundle-like-thing') + ubuntu_app = await model.deploy( + 'ubuntu-0', + application_name='ubuntu', + series='trusty', + channel='stable', + ) + ubuntu_app.on_unit_added(callback=lambda unit: True) + + await model.deploy( + 'nrpe-11', + application_name='nrpe', + series='trusty', + channel='stable', + num_units=0, + ) + await model.add_relation( + 'ubuntu', + 'nrpe', + ) + + result, ok = await model.block_until( + lambda: model.matches(goal_state), + timeout=600 + ) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + ws_logger = logging.getLogger('websockets.protocol') + ws_logger.setLevel(logging.INFO) + loop.run(main())