4 1. Connects to current model and resets it.
5 2. Deploys one ubuntu unit.
6 3. Runs an action against the unit.
7 4. Waits for the action results to come back, then exits.
12 from juju
.model
import Model
16 async def run_command(unit
):
17 logging
.debug('Running command on unit %s', unit
.name
)
19 # unit.run() returns a juju.action.Action instance
20 action
= await unit
.run('unit-get public-address')
21 logging
.debug("Action results: %s", action
.results
)
26 # connect to current model with current user, per Juju CLI
29 app
= await model
.deploy(
31 application_name
='ubuntu',
36 for unit
in app
.units
:
37 await run_command(unit
)
39 await model
.disconnect()
42 if __name__
== '__main__':
43 logging
.basicConfig(level
=logging
.DEBUG
)
44 ws_logger
= logging
.getLogger('websockets.protocol')
45 ws_logger
.setLevel(logging
.INFO
)