Skip to content

credentials.yaml must be present or lib wont work #996

@erik78se

Description

@erik78se

Description

I'm trying to use the juju library and have connection information in a database (endpoint,username,password,cacert)

But, when trying to connect to an endpoint, the credentials.yaml have to be available on the machine.

If its not, I get this error

Error connecting to controller my-controller. Error: [Errno 2] No such file or directory: '/root/.local/share/juju/controllers.yaml'

If I have the file present, the connection works.

Urgency

Annoying bug in our test suite

Python-libjuju version

2.9.46.0

Juju version

2.9.46

Reproduce / Test

async def test_jcontroller_async(jcontroller_instance):
        """
        Tests connection to a Juju controller.
        Returns True if connection is successful, False otherwise.
        """
        logger = logging.getLogger(__name__)
        controller = Controller()
        try:
            logger.info("Connecting to controller: %s", jcontroller_instance.name)
            #TODO: Remove password from logging
            logger.debug("Credentials: %s, %s, %s", jcontroller_instance.username, 
                         jcontroller_instance.password, jcontroller_instance.cacert)
            await controller.connect(endpoint=jcontroller_instance.endpointUrl,
                                    username=jcontroller_instance.username,
                                    password=jcontroller_instance.password,
                                    cacert=jcontroller_instance.cacert)
            if controller.is_connected():
                logger.info("Successfully connected to controller: %s", jcontroller_instance.name)
                await controller.disconnect()
                return True
            else:
                logger.warning("Could not connect to controller: %s", jcontroller_instance.name)
                return False
        except Exception as e:
            logger.error("Error connecting to controller %s. Error: %s", jcontroller_instance.name, str(e))
            return False

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugindicates a bug in the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions