--- /dev/null
+"""
+This example:
+
+1. Connects to the current model
+2. Resets it
+3. Deploys a charm and prints its config and constraints
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model
+
+
+async def run():
+ model = Model()
+ await model.connect_current()
+ await model.reset(force=True)
+
+ ubuntu_app = await model.deploy(
+ 'mysql',
+ service_name='mysql',
+ series='trusty',
+ channel='stable',
+ constraints={
+ 'mem': 512 * 1024 * 1024
+ },
+ )
+ print(await ubuntu_app.get_config())
+ print(await ubuntu_app.get_constraints())
+
+ 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()
ws_logger = logging.getLogger('websockets.protocol')
ws_logger.setLevel(logging.INFO)
loop = asyncio.get_event_loop()
-loop.set_debug(False)
+loop.set_debug(True)
loop.create_task(run())
loop.run_forever()
return await app_facade.Expose(self.name)
- def get_config(self):
- """Return the configuration settings for this application.
+ async def get_config(self):
+ """Return the configuration settings dict for this application.
"""
- pass
+ app_facade = client.ApplicationFacade()
+ app_facade.connect(self.connection)
+
+ log.debug(
+ 'Getting config for %s', self.name)
+
+ return (await app_facade.Get(self.name)).config
- def get_constraints(self):
- """Return the machine constraints for this application.
+ async def get_constraints(self):
+ """Return the machine constraints dict for this application.
"""
- pass
+ app_facade = client.ApplicationFacade()
+ app_facade.connect(self.connection)
+
+ log.debug(
+ 'Getting constraints for %s', self.name)
+
+ return vars((await app_facade.Get(self.name)).constraints)
def get_actions(self, schema=False):
"""Get actions defined for this application.
- series is required; how do we pick a default?
"""
- if constraints:
- constraints = client.Value(**constraints)
-
if to:
placement = [
client.Placement(**p) for p in to