Triggering relation events?
nick.barcet at canonical.com
Sun Dec 18 09:04:47 UTC 2011
On 12/17/2011 07:26 PM, Juan Negron wrote:
> Hi Nick:
> One way to do that is to put that code in a config-changed hook which
> will get called when you change the variables with juju set.
> This will ensure that every time you change something with juju set, it
> gets propagated via the config-changed hook as the configuration would
> have changed on all of the units of that service.
Thanks Juan, but I do not think this would work, as a in order to copy a
file with scp or rsync between two units you need to be able to
establish a conversation between the two host. Here is an example of
this for when the ssh keys have not been shared yet:
# LEADER SLAVE
# <------------------- set scp-hostname
# set scp-ssh-key ----------------->
# save shh-keys
# <------------------- set scp-ssh-key-saved
# do file copy
# set scp-copy-done --------------->
This is only possible to do, AFAIK, in a relation environment where
changing a relational parameter will trigger a relation-changed event on
the other side. When you are in a config-changed event, you not have
access to relation-[set/get] since you do not have any context for a
relation, nor can you do a 'juju set <service> <var>=<value>' because
this can only be used outside of the environment. This basically
prevents a two way conversation to occur.
> On Sat, Dec 17, 2011 at 9:24 AM, Nick Barcet <nick.barcet at canonical.com
> <mailto:nick.barcet at canonical.com>> wrote:
> I've been having fun during my week of vacation contributing a few
> charms and a ch_peer_copy function for charm-helpers  which
> allowed me to automatically copy the certificates and des_key that
> are in the "leader" unit of roundcube to all the other units .
> This works great and shows the power of peer relations, but brings
> a small question:
> Let's imagine that at some point in the future I need to update this
> certificate (let's say, when it expires). I can upload the new
> certs to the machine using 'juju scp'. I can update the
> configuration of my units using 'juju set'. My problem is how do I
> trigger a change even on all the peer relations so that the
> certificates are copied again? I could not find any way to force an
> event in the doc. Maybe I am taking the wrong approach to this?
>  https://code.launchpad.net/~__nijaba/charm-tools/peer-scp
> Juju mailing list
> Juju at lists.ubuntu.com <mailto:Juju at lists.ubuntu.com>
> Modify settings or unsubscribe at:
More information about the Juju