Defining a charm that supports multiple interfaces for the same relationship
Bruno Girin
brunogirin at gmail.com
Mon Nov 5 16:23:46 UTC 2012
Hi all,
I had a chat with Marco on Thursday about supporting multiple interfaces
on the same relationship and we couldn't come to a sensible conclusion
(beer may not have helped) so we concluded that we should put the
question to the wisdom of the mailing list. Here goes.
Use case: say you have a web app that needs to connect to a database and
supports either MySQL or PostgreSQL. How should I define that in
metadata.yaml and how do I handle it in the relation-changed hook?
If I specify this:
requires:
db1:
interface: mysql
db2:
interface: postgresql
it's a bit verbose and does not enforce the fact that I want either db1
or db2 but not both. Can I use the same name for both relationships? As in:
requires:
db:
interface: mysql
db:
interface: postgresql
Or even specify several interfaces for the same relationship:
requires:
db:
interface: mysql
interface: postgresql
Or even better:
requires:
db:
interface: [ mysql, postgresql ]
Then, will I be able to call something like "relation-get interface" in
the db-relation-changed hook in order to install the correct client
libraries depending on the interface supported by the other side of the
relationship?
Cheers,
Bruno
More information about the Juju
mailing list