I’m in a bash hook trying to detect if my unit is related or not to something else (in this case Bind9 dns-entry)…
I only found this in the docs :
I tried
< another-relation >-changed.sh
RELATION_LIST=$(relation-ids dns-entry) #This returns `dns-entry:7` .. with 7 being the unit #
RELATION_DETAILS=$(relation-get -r $RELATION_LIST)
it is this second line which gives me a permission denied… what is the right way to check my units relations …and then get more details on that relation if it exists?? thank you.
EDIT: ah hah! I seem to have cracked the problem… but revealed a new problem
if I pass in the unit name and number of the application providing the relation … I get the data expected… but now my question is, how do I get the UNIT_NUMBER for a specific relation if I am running in a hook that is NOT from that relation??
ie I have relation 1 …
and relation 2…
in relation 2 hook-changed… I want to get the unit number or blank if nothing related … for relation 1
Is this possible ?
I tried to use goal-state command however because this unit I am relating to is a cross-model relation… i do NOT get the Unit number from this … and what I do get does not work for the relation-get command
I think there’s some confusion. There is no UNIT_NUMBER linked to every relation at any given time. When the unit receives a relation event say, changed, then UNIT_NUMBER is set and the semantics is: UNIT_NUMBER := the remote unit ID that has changed the data of this relation.
However when you are processing a different event (or a relation event for a different relation, there is no such thing as ‘the UNIT_NUMBER for the other relation’, because there’s nothing going on (so far as the charm is concerned) with the other relation.
So you need to ask yourself: what unit ID are you looking for, and why?