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.
14 from juju
.model
import Model
17 async def run_action(unit
):
18 logging
.debug('Running action on unit %s', unit
.name
)
20 # unit.run() returns a juju.action.Action instance
21 action
= await unit
.run_action('add-repo', repo
='myrepo')
22 # wait for the action to complete
23 action
= await action
.wait()
25 logging
.debug("Action results: %s", action
.results
)
30 await model
.connect_current()
31 await model
.reset(force
=True)
33 app
= await model
.deploy(
35 application_name
='git',
40 for unit
in app
.units
:
41 await run_action(unit
)
43 await model
.disconnect()
46 if __name__
== '__main__':
47 logging
.basicConfig(level
=logging
.DEBUG
)
48 ws_logger
= logging
.getLogger('websockets.protocol')
49 ws_logger
.setLevel(logging
.INFO
)