X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=docs%2Fnarrative%2Fapplication.rst;h=01d5bc0d2d3cf22debe8f73f78c467b1699c94eb;hb=19077c2754a4296a87a80679e876e67cfed57c5c;hp=c255a37f5cde40d1bd30fbe8f76a635217bb2585;hpb=843e6a04a7f92cc7efdcc75ae0bb4be3fb0ca027;p=osm%2FN2VC.git diff --git a/docs/narrative/application.rst b/docs/narrative/application.rst index c255a37..01d5bc0 100644 --- a/docs/narrative/application.rst +++ b/docs/narrative/application.rst @@ -1,5 +1,6 @@ Applications ============ +For api docs, see :class:`juju.application.Application`. Deploying @@ -39,14 +40,14 @@ added units (:class:`~juju.unit.Unit` objects) is returned. .. code:: python - ubuntu_app = await model.deploy( - 'ubuntu', - application_name='ubuntu', - series='trusty', - channel='stable', - ) + ubuntu_app = await model.deploy( + 'ubuntu', + application_name='ubuntu', + series='trusty', + channel='stable', + ) - unit_a, unit_b = await ubuntu_app.add_units(count=2) + unit_a, unit_b = await ubuntu_app.add_units(count=2) Updating Config and Constraints @@ -70,3 +71,46 @@ application. The `mysql_app` object is an instance of constraints = await mysql_app.get_constraints() assert(constraints['mem'] == 512 * MB) + + +Adding and Removing Relations +----------------------------- +The :meth:`juju.application.Application.add_relation` method returns a +:class:`juju.relation.Relation` instance. + +.. code:: python + + from juju.model import Model + + model = Model() + await model.connect_current() + + # Deploy mysql-master application + mysql_master = await model.deploy( + 'cs:mysql-55', + application_name='mysql-master', + series='trusty', + channel='stable', + ) + + # Deploy mysql-slave application + mysql_slave = await model.deploy( + 'cs:mysql-55', + application_name='mysql-slave', + series='trusty', + channel='stable', + ) + + # Add the master-slave relation + relation = await mysql_master.add_relation( + # Name of the relation on the local (mysql-master) side + 'master', + # Name of the app:relation on the remote side + 'mysql-slave:slave', + ) + + # Remove the relation + await mysql_master.remove_relation( + 'master', + 'mysql-slave:slave', + )