3 For api docs, see :class:`juju.application.Application`.
8 To deploy a new application, connect a model and then call its
9 :meth:`~juju.model.Model.deploy` method. An
10 :class:`~juju.application.Application` instance is returned.
14 from juju.model import Model
17 await model.connect_current()
19 mysql_app = await model.deploy(
20 # If a revision number is not included in the charm url,
21 # the latest revision from the Charm Store will be used.
23 application_name='mysql',
27 'tuning-level': 'safest',
37 To add units to a deployed application, use the
38 :meth:`juju.application.Application.add_units` method. A list of the newly
39 added units (:class:`~juju.unit.Unit` objects) is returned.
43 ubuntu_app = await model.deploy(
45 application_name='ubuntu',
50 unit_a, unit_b = await ubuntu_app.add_units(count=2)
53 Updating Config and Constraints
54 -------------------------------
55 Example showing how to update configuration and constraints on a deployed
56 application. The `mysql_app` object is an instance of
57 :class:`juju.application.Application`.
63 # Update and check app config
64 await mysql_app.set_config({'tuning-level': 'fast'})
65 config = await mysql_app.get_config()
67 assert(config['tuning-level']['value'] == 'fast')
69 # update and check app constraints
70 await mysql_app.set_constraints({'mem': 512 * MB})
71 constraints = await mysql_app.get_constraints()
73 assert(constraints['mem'] == 512 * MB)
76 Adding and Removing Relations
77 -----------------------------
78 The :meth:`juju.application.Application.add_relation` method returns a
79 :class:`juju.relation.Relation` instance.
83 from juju.model import Model
86 await model.connect_current()
88 # Deploy mysql-master application
89 mysql_master = await model.deploy(
91 application_name='mysql-master',
96 # Deploy mysql-slave application
97 mysql_slave = await model.deploy(
99 application_name='mysql-slave',
104 # Add the master-slave relation
105 relation = await mysql_master.add_relation(
106 # Name of the relation on the local (mysql-master) side
108 # Name of the app:relation on the remote side
112 # Remove the relation
113 await mysql_master.remove_relation(