European Bob's Hula Hoopla!

Sat, 09 Jul 2005

Hacking Hula's schema

A while ago I posted about updating the Hula schema when upgrading packages, but haven't really had time to look at the various issues since then.

My first problem of translating a diff of the schemas into actual actions is still there, but looks doable. Thing is, it's semi-obvious what to do - but you end up throwing away some of the information that's available to you, which makes me think it might be wrong. I guess the thing to do is try it and see.

The second problem - what information is instantiated by default? Well, I wrote another script to figure that out. Rather than try and work it out from the code, this just looks inside a directory structure that has been created. This isn't necessarily right either, but seems close enough for now. The output looks something like this:

name:root
        object%032class:Top
        t:Tree

name:root/context
        object%032class:Organization
        o:Context

name:root/context/admin
        object%032class:User
        cn:admin
        surname:Admin
        private%032key:aHVsyQ==

These are the first three objects output, in an ldif-ish format with some of my own naming convention :o).

So, I now have a textual version of the schema, and the initial tree. Theoretically, it should now be possible to write a hulasetup which takes those two files and does roughly the same as our current hulasetup (albeit in vastly less code, I suspect). There are three attributes that cannot be stored in the files (they're auto-generated random pads), which I'm not sure what to do with, but although it will be a hack it won't be too bad.

Once we have this new version of hulasetup, it should be possible to do a number of cool things:

Next steps: first, see if I can normalise the output formats of these various scripts (maybe even proper LDIF; this would fit in with Pat Felt's ldap plans). Second, write a tool to diff them (diff itself won't cut it for various reasons). Then, write a tool which "actions" the diff via the MDB library, to replace my hulaupdateschema program. Technically, this latter tool could also replace hulasetup (in the special case of comparing a new schema with an empty file). I have a kind-of cunning idea for this last bit too, but we'll see if it's workable.

If you'd like to take a peek at my scripts, they're here (this is a .tar.bz2), including my "hulaupdateschema". Beware with the latter - it was written with my Debian packages in mind, and is a bit hackish - it's certainly not a long-term solution.