Defining a new interface

Torsten Schlabach TSchlabach at gmx.net
Tue Nov 6 15:38:29 UTC 2012


Hi Bruno!

Thanks for the clarifications.

Just I think there is one puzzle piece missing yet.

So I will write two charms:

openldap:

provides:
  directory:
    interface: ldapv3


adressbookapp:

requires:
  directory:
    interface: ldapv3


I assume there has to be some magic hidden in the Juju harness which would then go ahead and upon creation of a directory-ldap relationship create a user in the LDAP server for me (maybe also add schemas, but this is different piece of cake) and provide the ldap server host, port and credentials in some variables in my addressbookapp add-relation hook?

To continue the MySQL analogy, I am looking at Wordpress:

http://bazaar.launchpad.net/~charmers/charms/precise/wordpress/trunk/view/head:/hooks/db-relation-changed

Lines 15-18 are:

database=`relation-get database`
user=`relation-get user`
password=`relation-get password`
host=`relation-get private-address`

So in my adressbookapp charm I guess I would write a hook called directory-relation-changed which reads

ldaptreeroot=`relation-get ldaptreeroot`
userDN=`relation-get userDN`
password=`relation-get password`
host=`relation-get private-address`

Can I just write into my directory-relation-joined hook in my openldap charm:

relation-set userDN=cn=admin,o=world
...

and that's it?

Looking at the actual mysql charm, I still have the problem that I can spot where the password is generated, where the hostname comes from but not how the name of the user and the database is generated. The values of user and database_name variables seem to be defined outside that hook script. Just as a side question ...

Regards,
Torsten

-------- Original-Nachricht --------
> Datum: Tue, 06 Nov 2012 15:11:59 +0000
> Von: Bruno Girin <brunogirin at gmail.com>
> An: juju at lists.ubuntu.com
> Betreff: Re: Defining a new interface

> On 06/11/12 12:45, Torsten Schlabach wrote:
> > Dear Juju experts!
> >
> > We are in the process to write some charms which we will need for our
> services. Part of that involves LDAP. So we think we should create an LDAP
> server charm and then have a couple of other charms which install services
> which require an LDAP server connection. So this is pretty similar to the
> concept of deploying MySQL using the MySQL charm, then deploying for example
> Drupal which connects to MySQL.
> 
> That sounds brilliant!
> 
> > Now obviously there is a concept of interfaces in Juju, possibly with
> some inheritance, i.e. there is a db interface with a subclass of MySQL which
> obviously defined that for a MySQL connection one needs four parameters
> (server IP, database name, username and password).
> 
> Not quite. When you see in a charm something like:
> 
> provides:
>   db:
>     interface: mysql
> 
> It means that the charm provides a mysql interface over a relationship
> called db. The name of the relationship (db) is just here to help Juju
> differentiate when you have multiple interfaces but doesn't imply
> anything. What's important is the fact that the interface is called
> mysql. Basically, when you run juju add-relation a b, it will check that
> "a" can connect to "b" over the same interface irrespective of their
> names.
> 
> So for example, the two below can connect because one provides an
> interface that the other one requires with the same interface name. The
> fact that the relationships have different names doesn't matter:
> 
> Charm A:
> 
> requires:
>   internal-db:
>     interface: mysql
> 
> Charm B:
> 
> provides:
>   db:
>     interface: mysql
> 
> > Now we wonder if there is already a db:ldap interface. We couldn't spot
> one, actually. We also wonder if we shall treat LDAP as a subtype of db or
> independently.
> 
> There isn't an interface defined as such, it's just a name in a charm's
> yaml file. So I would suggest something like this for your LDAP charm:
> 
> provides:
>   directory:
>     interface: ldap
> 
> > But we wonder the most where and how those classes are defined /
> documented and how we could implement our own class. We may also need some
> additional interface later, such as mail:imap or smtp for example.
> >
> > Any pointers are welcome.
> 
> I hope the answers above help!
> 
> PS: if some real experts spot any mistakes in my explanations, please
> correct me!
> 
> Cheers,
> 
> Bruno
> 
> 
> -- 
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju




More information about the Juju mailing list