8267df7bf829600a176f4a5162520422fce702aa
[osm/N2VC.git] / docs / narrative / unit.rst
1 Units
2 =====
3
4 Running Commands
5 ----------------
6 Run arbitrary commands on a unit with the
7 :meth:`juju.unit.Unit.run` method. This method blocks
8 the current coroutine until a result is available, and
9 returns a :class:`juju.action.Action` instance.
10
11
12 .. code:: python
13
14   from juju.model import Model
15
16   model = Model()
17   await model.connect_current()
18
19   ubuntu_app = await model.deploy(
20       'ubuntu',
21       application_name='ubuntu',
22       series='trusty',
23       channel='stable',
24   )
25
26   for unit in app.units:
27       action = await unit.run('unit-get public-address')
28       print(action.results)
29
30       action = await unit.run('uname -a')
31       print(action.results)
32
33