How to use the juju.controller.Controller 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 openstack-charmers / zaza / zaza / controller.py View on Github external
async def async_list_models():
    """Return a list of tha available clouds.

    :returns: List of clouds
    :rtype: list
    """
    controller = Controller()
    await controller.connect()
    models = await controller.list_models()
    await controller.disconnect()
    return models
github openstack-charmers / zaza / zaza / controller.py View on Github external
async def async_cloud(name=None):
    """Return information about cloud.

    :param name: Cloud name. If not specified, the cloud where
                 the controller lives on is returned.
    :type name: Optional[str]
    :returns: Information on all clouds in the controller.
    :rtype: CloudResult
    """
    controller = Controller()
    await controller.connect()
    cloud = await controller.cloud(name=name)
    await controller.disconnect()
    return cloud
github conjure-up / conjure-up / conjureup / juju.py View on Github external
async def model_available():
    """ Check whether selected model is already available.
    """
    if app.provider.controller is None:
        raise Exception("No controller selected")

    if app.provider.model is None:
        raise Exception("No model selected.")

    controller = Controller(app.loop)
    await controller.connect(app.provider.controller)
    try:
        models = await controller.list_models()
        return app.provider.model in models
    finally:
        await controller.disconnect()
github juju-solutions / matrix / matrix / rules.py View on Github external
if bundle_suite.exists():
                filenames.append(str(bundle_suite))

        if not filenames:
            log.critical('No test suites to run')

        tests = load_suites(filenames)

        if not self.path.samefile(Path.cwd()):
            sys.path.append(str(self.path))  # for custom tasks

        context = model.Context(
                loop=self.loop,
                bus=self.bus,
                config=self,
                juju_controller=juju.controller.Controller(self.loop),
                suite=tests)
        return context
github openstack-charmers / zaza / zaza / controller.py View on Github external
async def async_get_cloud():
    """Return the name of the current cloud.

    :returns: Name of cloud
    :rtype: str
    """
    controller = Controller()
    await controller.connect()
    cloud = await controller.get_cloud()
    await controller.disconnect()
    return cloud
github conjure-up / conjure-up / conjureup / juju.py View on Github external
async def create_model():
    """ Creates the selected model.
    """
    if app.provider.controller is None:
        raise Exception("No controller selected")

    if app.provider.model is None:
        raise Exception("No model selected.")

    controller = Controller(app.loop)
    await controller.connect(app.provider.controller)
    try:
        app.juju.client = await controller.add_model(
            model_name=app.provider.model,
            cloud_name=app.provider.cloud,
            region=app.provider.region,
            credential_name=app.provider.credential,
            config=app.conjurefile.get('model-config', None))
        events.ModelConnected.set()
    finally:
        await controller.disconnect()
github openstack-charmers / zaza / zaza / controller.py View on Github external
async def async_destroy_model(model_name):
    """Remove a model from the current controller.

    :param model_name: Name of model to remove
    :type model_name: str
    """
    controller = Controller()
    await controller.connect()
    logging.debug("Destroying model {}".format(model_name))
    await controller.destroy_model(model_name)
    await controller.disconnect()
github openstack-charmers / zaza / zaza / controller.py View on Github external
async def async_add_model(model_name, config=None, region=None):
    """Add a model to the current controller.

    :param model_name: Name to give the new model.
    :type model_name: str
    :param config: Model configuration.
    :type config: dict
    :param region: Region in which to create the model.
    :type region: str
    """
    controller = Controller()
    await controller.connect()
    logging.debug("Adding model {}".format(model_name))
    model = await controller.add_model(
        model_name, config=config, region=region)
    # issue/135 It is necessary to disconnect the model here or async spews
    # tracebacks even during a successful run.
    await model.disconnect()
    await controller.disconnect()