On 11 January 2017 at 20:23, Tilman Baumann <tilman.baum...@canonical.com> wrote:
> Hi, > > I'm writing a layered reactive-python charm which uses a peer relation > to know all units of the same application. > > However I don't seem to find a way to convince charm build to create the > ./hook/ files for this relation for me. > 'charm build' will only create the hook files for interfaces included by your layer.yaml. If you don't want that, then you need to create the hooks yourself in your charm. You do this by copying https://github.com/juju- solutions/layer-basic/blob/master/hooks/hook.template to your hooks/foo-relation-{joined,changed,departed,broken} files and making them executable. It would be nice if 'charm build' handled this for you, but nobody has gotten around to implementing the feature. What is the general best practice for providing peer relations of a own > type in a layered charm? > Have a look at layer:coordinator for a layer with a 'private' peer relation. I don't think there is a best practice yet, but it is how I did it :) https://code.launchpad.net/layer-coordinator or https://github.com/stub42/layer-coordinator I suppose there is no reason why I can't put the code in a class based > off RelationBase like interface layers usually do? The code entry point > seems to the @hook decorators around the methods. I don't need to create > instances or anything like that, right? > Yes. There is nothing magical about interface layers - they are just like any other layer, except with more arbitrary restrictions and their code copied into a hooks/relations rather than the top level. You can most certainly store this code in your main charm or layers tree rather than in a separate branch pulled in at build time. -- Stuart Bishop <stuart.bis...@canonical.com>
-- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju