blob: bacc840a04e56f7d040b5a909e80ea1c0acb97c7 [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example:
3
41. Connects to the current model
52. Resets it
63. Deploys a charm and prints its config and constraints
7
8"""
9import asyncio
10import logging
11
12from juju.model import Model
13from juju import loop
14
15log = logging.getLogger(__name__)
16
17MB = 1
18
19
20async def main():
21 model = Model()
22 await model.connect_current()
23 await model.reset(force=True)
24
25 ubuntu_app = await model.deploy(
26 'mysql',
27 application_name='mysql',
28 series='trusty',
29 channel='stable',
30 config={
31 'tuning-level': 'safest',
32 },
33 constraints={
34 'mem': 256 * MB,
35 },
36 )
37
38 # update and check app config
39 await ubuntu_app.set_config({'tuning-level': 'fast'})
40 config = await ubuntu_app.get_config()
41 assert(config['tuning-level']['value'] == 'fast')
42
43 # update and check app constraints
44 await ubuntu_app.set_constraints({'mem': 512 * MB})
45 constraints = await ubuntu_app.get_constraints()
46 assert(constraints['mem'] == 512 * MB)
47
48 await model.disconnect()
49
50
51if __name__ == '__main__':
52 logging.basicConfig(level=logging.DEBUG)
53 ws_logger = logging.getLogger('websockets.protocol')
54 ws_logger.setLevel(logging.INFO)
55 loop.run(main())