Defining a new interface

Bruno Girin brunogirin at gmail.com
Tue Nov 6 15:11:59 UTC 2012


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




More information about the Juju mailing list