X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=examples%2Fconfig.py;h=bacc840a04e56f7d040b5a909e80ea1c0acb97c7;hb=d129a513c38139c809cefb99d433a686dcc9f78a;hp=616c7805e2e332ba73a33fbd4320133d631bc708;hpb=55ae2c120ce031f57ac210f3d7bd203db739f1e9;p=osm%2FN2VC.git diff --git a/examples/config.py b/examples/config.py index 616c780..bacc840 100644 --- a/examples/config.py +++ b/examples/config.py @@ -10,32 +10,46 @@ import asyncio import logging from juju.model import Model +from juju import loop +log = logging.getLogger(__name__) -async def run(): +MB = 1 + + +async def main(): model = Model() await model.connect_current() await model.reset(force=True) ubuntu_app = await model.deploy( 'mysql', - service_name='mysql', + application_name='mysql', series='trusty', channel='stable', + config={ + 'tuning-level': 'safest', + }, constraints={ - 'mem': 512 * 1024 * 1024 + 'mem': 256 * MB, }, ) - print(await ubuntu_app.get_config()) - print(await ubuntu_app.get_constraints()) + + # update and check app config + await ubuntu_app.set_config({'tuning-level': 'fast'}) + config = await ubuntu_app.get_config() + assert(config['tuning-level']['value'] == 'fast') + + # update and check app constraints + await ubuntu_app.set_constraints({'mem': 512 * MB}) + constraints = await ubuntu_app.get_constraints() + assert(constraints['mem'] == 512 * MB) await model.disconnect() - model.loop.stop() - -logging.basicConfig(level=logging.DEBUG) -ws_logger = logging.getLogger('websockets.protocol') -ws_logger.setLevel(logging.INFO) -loop = asyncio.get_event_loop() -loop.set_debug(False) -loop.create_task(run()) -loop.run_forever() + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + ws_logger = logging.getLogger('websockets.protocol') + ws_logger.setLevel(logging.INFO) + loop.run(main())