Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am creating a Juju charm to encompass many Django development projects. I have the charm installing Django, wsgi, and Apache2. Django uses a separate database, user, and password for every project created. How do I provide these credentials to the charm when the mysql charm has only one set of database credentials? I would like to parse the python paths for all installed Django projects and have a mysql charm ready to use with them. As you can see below, the user will have to set these manually and change them when a new/different Django project is deployed to the cloud.

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

My question: Do I need to create a bash script to auto-create mysql charms with a correlating name to the Django project?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can create a new mysql charm with a new interface that can allocate dbs dynamically when requested and use that from your django charm, or deploy the projects as individual services.

Effectively the new interface for mysql would have the hooks allocate new dbs as requested by the connecting service, instead of creating them when the new service is related/connected to mysql.

Another alternative, fix your django projects to use table prefixes, which I thought they already did (or maybe that's app table prefixing with project).

Edit

The best solution might be to just use an admin interface relation, which gives you the root user on mysql and then you can create additional dbs as needed (pointed out to me on irc by clint) for all the django projects installed.

share|improve this answer
    
Ya, makes sense. Only, there does not seem to be much documentation on interfaces in the web. Have I overlooked it somewhere? –  surgemcgee May 22 '12 at 19:11
1  
-1, there is no need to fork the mysql charm. See my answer below. –  SpamapS May 22 '12 at 20:03

The mysql charm has multiple interfaces, one of which is designed specifically for your app to have admin privileges over the whole server. So you would just make your relation

requires:
  db:
    interface: mysql-root

This will guarantee you a "root" users with privileges that you can use to create databases/users/etc. You won't get a 'database', since you can create any database, so keep that in mind.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.