To answer your question anyways, you can do this with the peers relation:
``` metadata.yaml
peers:
cluster:
interface: my-service-cluster
```
So, at anytime, in any hook you can do the following:
``` bash
rid=$(relation-ids cluster)
for unit in $(relation-list -r $rid); do
echo "It's a peer and confidant $unit"
done
```
However, since Juju gives unique numbers for each unit, you could use a
units number to enumerate a port. You wouldn't need the peer relationship
for this directly. As an example
``` bash
port_start=4000
port=$(expr $port_start + ${JUJU_UNIT_NAME##*/})
```
So if it's unit/0 you'll get 4000, if it's unit/10 you'll get 4010, etc.
Since unit numbers are unique in Juju you'll never get a conflict.
Marco Ceppi
On Wed, Mar 2, 2016 at 6:29 AM Tom Barber <[email protected]> wrote:
> Scrap that, I have an alternative solution!
>
> --------------
>
> Director Meteorite.bi - Saiku Analytics Founder
> Tel: +44(0)5603641316
>
> (Thanks to the Saiku community we reached our Kickstart
> <http://kickstarter.com/projects/2117053714/saiku-reporting-interactive-report-designer/>
> goal, but you can always help by sponsoring the project
> <http://www.meteorite.bi/products/saiku/sponsorship>)
>
> On 2 March 2016 at 11:22, Tom Barber <[email protected]> wrote:
>
>> Morning
>>
>> I need to open an extra port for each unit in my charm, can I ask juju
>> for a count of running units in a service?
>>
>> Thanks
>>
>> Tom
>>
>
> --
> Juju mailing list
> [email protected]
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>
--
Juju mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/juju