X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=examples%2Funitrun.py;h=b6e2240ab74bf9b15951d1e18502b4fb061b0507;hb=HEAD;hp=805f0ae0d3dc9144eb3f115c230fee813506f449;hpb=b8a8281b1785358bd5632a119c016f21811172c6;p=osm%2FN2VC.git diff --git a/examples/unitrun.py b/examples/unitrun.py deleted file mode 100644 index 805f0ae..0000000 --- a/examples/unitrun.py +++ /dev/null @@ -1,46 +0,0 @@ -""" -This example: - -1. Connects to current model and resets it. -2. Deploys one ubuntu unit. -3. Runs an action against the unit. -4. Waits for the action results to come back, then exits. - -""" -import logging - -from juju.model import Model -from juju import loop - - -async def run_command(unit): - logging.debug('Running command on unit %s', unit.name) - - # unit.run() returns a juju.action.Action instance - action = await unit.run('unit-get public-address') - logging.debug("Action results: %s", action.results) - - -async def main(): - model = Model() - # connect to current model with current user, per Juju CLI - await model.connect() - - app = await model.deploy( - 'ubuntu-0', - application_name='ubuntu', - series='trusty', - channel='stable', - ) - - for unit in app.units: - await run_command(unit) - - await model.disconnect() - - -if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) - ws_logger = logging.getLogger('websockets.protocol') - ws_logger.setLevel(logging.INFO) - loop.run(main())