Retrieving the number of instances in an .erb template


Cyrille Le Clerc
 

Dear all,

I work on a boshrelease that can deploy 1..* Jenkins master and 1..*
Jenkins slaves. To dispatch the slaves between the master, I want to
implement a rule based on a modulus using the instance index and the total
number of instances.

I know how to retrieve the index of the instance in a .erb template with
<%= index %> (1)

How can I retrieve the total number of instances of a job?

Thanks for your help,

Cyrille

(1)
https://github.com/cloudfoundry-community/bosh-gen/blob/master/lib/bosh/gen/generators/job_generator/templates/jobs/%25job_name%25_simple/templates/data/properties.sh.erb#L8



--
Cyrille Le Clerc
email & gtalk : cleclerc(a)cloudbees.com / mob: +33-6.61.33.69.86 / skype:
cyrille.leclerc
CloudBees, Inc
www.cloudbees.com

<https://www.cloudbees.com/jenkins/juc-2015>
<https://www.cloudbees.com/cdsummit-2015>


Dmitriy Kalinin
 

Currently there is no way to do that unless you specify it as a property
and manually update it. This will be possible once we implement links:
https://github.com/cloudfoundry/bosh-notes/blob/master/links.md

On Mon, May 4, 2015 at 8:39 PM, Cyrille Le Clerc <cleclerc(a)cloudbees.com>
wrote:

Dear all,

I work on a boshrelease that can deploy 1..* Jenkins master and 1..*
Jenkins slaves. To dispatch the slaves between the master, I want to
implement a rule based on a modulus using the instance index and the total
number of instances.

I know how to retrieve the index of the instance in a .erb template with
<%= index %> (1)

How can I retrieve the total number of instances of a job?

Thanks for your help,

Cyrille

(1)
https://github.com/cloudfoundry-community/bosh-gen/blob/master/lib/bosh/gen/generators/job_generator/templates/jobs/%25job_name%25_simple/templates/data/properties.sh.erb#L8



--
Cyrille Le Clerc
email & gtalk : cleclerc(a)cloudbees.com / mob: +33-6.61.33.69.86 / skype:
cyrille.leclerc
CloudBees, Inc
www.cloudbees.com

<https://www.cloudbees.com/jenkins/juc-2015>
<https://www.cloudbees.com/cdsummit-2015>


_______________________________________________
cf-bosh mailing list
cf-bosh(a)lists.cloudfoundry.org
https://lists.cloudfoundry.org/mailman/listinfo/cf-bosh


Cyrille Le Clerc
 

Thanks Dmitriy,

I discussed with the Pivotal OpsManager team, I will use OpsManager's
capability to to inject the list of assigned IPs with ".ips" (1) and then
count the number of elements of this array.

I could also have used the ".instances" accessor but these IPs will help me
for other use cases.

Cyrille

(1) http://docs.pivotal.io/pivotalcf/packaging/#opsmanager_accessors

On Mon, May 4, 2015 at 9:03 PM, Dmitriy Kalinin <dkalinin(a)pivotal.io> wrote:

Currently there is no way to do that unless you specify it as a property
and manually update it. This will be possible once we implement links:
https://github.com/cloudfoundry/bosh-notes/blob/master/links.md

On Mon, May 4, 2015 at 8:39 PM, Cyrille Le Clerc <cleclerc(a)cloudbees.com>
wrote:

Dear all,

I work on a boshrelease that can deploy 1..* Jenkins master and 1..*
Jenkins slaves. To dispatch the slaves between the master, I want to
implement a rule based on a modulus using the instance index and the total
number of instances.

I know how to retrieve the index of the instance in a .erb template with
<%= index %> (1)

How can I retrieve the total number of instances of a job?

Thanks for your help,

Cyrille

(1)
https://github.com/cloudfoundry-community/bosh-gen/blob/master/lib/bosh/gen/generators/job_generator/templates/jobs/%25job_name%25_simple/templates/data/properties.sh.erb#L8



--
Cyrille Le Clerc
email & gtalk : cleclerc(a)cloudbees.com / mob: +33-6.61.33.69.86 / skype:
cyrille.leclerc
CloudBees, Inc
www.cloudbees.com

<https://www.cloudbees.com/jenkins/juc-2015>
<https://www.cloudbees.com/cdsummit-2015>


_______________________________________________
cf-bosh mailing list
cf-bosh(a)lists.cloudfoundry.org
https://lists.cloudfoundry.org/mailman/listinfo/cf-bosh

--
Cyrille Le Clerc
email & gtalk : cleclerc(a)cloudbees.com / mob: +33-6.61.33.69.86 / skype:
cyrille.leclerc
CloudBees, Inc
www.cloudbees.com

<https://www.cloudbees.com/jenkins/juc-2015>
<https://www.cloudbees.com/cdsummit-2015>