X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=docs%2Fnarrative%2Funit.rst;h=5d6b48d2c128dbf37d0d94854a88fa9e54db4fbf;hb=adc6e51ff00d513cd68d4a046e87b25adf2021be;hp=8267df7bf829600a176f4a5162520422fce702aa;hpb=8aca5190344dea43352b4d242291d729e3aa2328;p=osm%2FN2VC.git diff --git a/docs/narrative/unit.rst b/docs/narrative/unit.rst index 8267df7..5d6b48d 100644 --- a/docs/narrative/unit.rst +++ b/docs/narrative/unit.rst @@ -1,5 +1,7 @@ Units ===== +For api docs, see :class:`juju.unit.Unit`. + Running Commands ---------------- @@ -16,7 +18,7 @@ returns a :class:`juju.action.Action` instance. model = Model() await model.connect_current() - ubuntu_app = await model.deploy( + app = await model.deploy( 'ubuntu', application_name='ubuntu', series='trusty', @@ -31,3 +33,33 @@ returns a :class:`juju.action.Action` instance. print(action.results) +Running Actions +--------------- +Run actions on a unit with the +:meth:`juju.unit.Unit.run_action` method. This method +returns a :class:`juju.action.Action` instance immediately. To block until +the action completes, use the :meth:`juju.action.Action.wait` method, as +in the example below. + + +.. code:: python + + from juju.model import Model + + model = Model() + await model.connect_current() + + app = await model.deploy( + 'git', + application_name='git', + series='trusty', + channel='stable', + ) + + for unit in app.units: + # run the 'add-repo' action, passing a 'repo' param + action = await unit.run_action('add-repo', repo='myrepo') + # wait for the action to complete + action = await action.wait() + + print(action.results)