Ejemplo n.º 1
0
    def root_password(self):
        """MongoDB root password.
        """
        root_password = None
        peers = self.peers

        data = self.peers.data[peers.app]
        root_password = data.get('root_password', None)

        if root_password is None:
            root_password = MongoDB.new_password()

        return root_password
Ejemplo n.º 2
0
    def credentials(self, rel_id):
        """Fetch credentials associated with a relation.

        Args:
           rel_id: integer id of relation

        Returns:
           A dictionary with keys "username" and "password".
        """
        consumers = self.consumers()

        if self.is_new_relation(rel_id):
            creds = {
                'username': self.new_username(rel_id),
                'password': MongoDB.new_password()
            }
            consumers[rel_id] = creds

            self.charm.peers.data[self.charm.app]['consumers'] = json.dumps(
                consumers)
        else:
            creds = consumers[rel_id]
        return creds