How to use the juju.client.connection.Connection function in juju

To help you get started, we’ve selected a few juju examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github juju / juju / acceptancetests / assess_model_change_watcher.py View on Github external
def run_listener(client, event, juju_bin):
    logging.info("Running listener.")
    loop = asyncio.get_event_loop()
    future = asyncio.Future()

    logging.info("Connect to the current model.")
    os.environ['JUJU_DATA'] = client.env.juju_home
    os.environ['PATH'] = "{}{}{}".format(
        juju_bin, os.pathsep, os.environ.get('PATH', ''))
    conn = loop.run_until_complete(Connection.connect_current())
    logging.info("Connected to the current model.")

    asyncio.ensure_future(listen_to_watcher(event, conn, future))
    return loop, future