X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fexamples%2Fconfig.py;fp=modules%2Flibjuju%2Fexamples%2Fconfig.py;h=0000000000000000000000000000000000000000;hp=c7580f6300f53e5c6f1f3f88465800637bacb20f;hb=5aa242fe2d61c2da9fdb29ed65029f3e27b6966d;hpb=e2051cca7dac12aa09f6ed33555dcc4548c4b52b diff --git a/modules/libjuju/examples/config.py b/modules/libjuju/examples/config.py deleted file mode 100644 index c7580f6..0000000 --- a/modules/libjuju/examples/config.py +++ /dev/null @@ -1,54 +0,0 @@ -""" -This example: - -1. Connects to the current model -2. Resets it -3. Deploys a charm and prints its config and constraints - -""" -import logging - -from juju.model import Model -from juju import loop - -log = logging.getLogger(__name__) - -MB = 1 - - -async def main(): - model = Model() - # connect to current model with current user, per Juju CLI - await model.connect() - - ubuntu_app = await model.deploy( - 'mysql', - application_name='mysql', - series='trusty', - channel='stable', - config={ - 'tuning-level': 'safest', - }, - constraints={ - 'mem': 256 * MB, - }, - ) - - # 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() - - -if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) - ws_logger = logging.getLogger('websockets.protocol') - ws_logger.setLevel(logging.INFO) - loop.run(main())