616c7805e2e332ba73a33fbd4320133d631bc708
[osm/N2VC.git] / examples / config.py
1 """
2 This example:
3
4 1. Connects to the current model
5 2. Resets it
6 3. Deploys a charm and prints its config and constraints
7
8 """
9 import asyncio
10 import logging
11
12 from juju.model import Model
13
14
15 async def run():
16 model = Model()
17 await model.connect_current()
18 await model.reset(force=True)
19
20 ubuntu_app = await model.deploy(
21 'mysql',
22 service_name='mysql',
23 series='trusty',
24 channel='stable',
25 constraints={
26 'mem': 512 * 1024 * 1024
27 },
28 )
29 print(await ubuntu_app.get_config())
30 print(await ubuntu_app.get_constraints())
31
32 await model.disconnect()
33 model.loop.stop()
34
35 logging.basicConfig(level=logging.DEBUG)
36 ws_logger = logging.getLogger('websockets.protocol')
37 ws_logger.setLevel(logging.INFO)
38 loop = asyncio.get_event_loop()
39 loop.set_debug(False)
40 loop.create_task(run())
41 loop.run_forever()