4 1. Connects to current model and resets it.
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
16 async def run_action(unit
):
17 logging
.debug('Running action on unit %s', unit
.name
)
19 # unit.run() returns a juju.action.Action instance
20 action
= await unit
.run_action('add-repo', repo
='myrepo')
21 # wait for the action to complete
22 action
= await action
.wait()
24 logging
.debug("Action results: %s", action
.results
)
29 # connect to current model with current user, per Juju CLI
32 app
= await model
.deploy(
34 application_name
='git',
39 for unit
in app
.units
:
40 await run_action(unit
)
42 await model
.disconnect()
45 if __name__
== '__main__':
46 logging
.basicConfig(level
=logging
.DEBUG
)
47 ws_logger
= logging
.getLogger('websockets.protocol')
48 ws_logger
.setLevel(logging
.INFO
)