How to get ip addresses of all units in a service in Juju charm?

admin

Administrator
Staff member
I am new to Juju and trying to write a charm. I need ip address of all units deployed in a service. I am using

e.g.I have 3 units of wordpress with--
juju deploy -n 3 cs:wordpress

I deployed my charm from local repo -- juju deploy local:trusty/X

I add relation between the two-- juju add-relation X wordpress

Now, I need list of all 3 ip addresses of wordpress service in one of the hook in my charm(X)

I set relation-keys in wordpress and tried using relation-ids -> relation-list -> relation-get hook tools in my charm.
But it gives me just one ip and not all three.

relation-ids --gives one id.
relation-list id --gives just one unit.
relation-get --gives corresponding ip.

what should I do to get expected result?