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.
13 from juju
.model
import Model
17 async def run_command(unit
):
18 logging
.debug('Running command on unit %s', unit
.name
)
20 # unit.run() returns a juju.action.Action instance
21 action
= await unit
.run('unit-get public-address')
22 logging
.debug("Action results: %s", action
.results
)
27 await model
.connect_current()
28 await model
.reset(force
=True)
30 app
= await model
.deploy(
32 application_name
='ubuntu',
37 for unit
in app
.units
:
38 await run_command(unit
)
40 await model
.disconnect()
43 if __name__
== '__main__':
44 logging
.basicConfig(level
=logging
.DEBUG
)
45 ws_logger
= logging
.getLogger('websockets.protocol')
46 ws_logger
.setLevel(logging
.INFO
)