Hi Peter,

I don't have a Brooklyn to hand to verify this but I think you can get the
ID you want with $brooklyn:entityId().

There doesn't seem to be any documentation on this, to my surprise, but you
can see an example of its use in the Java code for tests here:

https://github.com/apache/brooklyn-server/blob/c782aae54f424e317c0999f5cde3fab19bc45cfb/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/DslYamlTest.java#L433

Alternatively this is equivalent to $brooklyn:attributeWhenReady("entity.id")
as used for example here:

https://github.com/brooklyncentral/clocker/blob/master/kubernetes/catalog/kubernetes/kubernetes.bom#L492

Regards
Geoff




On Thu, 1 Aug 2019 at 22:10, Peter Abramowitsch <[email protected]>
wrote:

> Hi Brooklyn experts
>
> I'm trying to create a cluster where each instance has a unique id that I
> can feed to the process during the customize and launch stages, so I
> thought of using the entity's own ID.  I've tried many ways to get the id
> just before customize, but none of them work.   The entity in question is
> of type VanillaJavaApp
>
> Here's one example
>
> This one fails giving "Cannot coerce type
> org.apache.brooklyn.core.sensor.BasicAttributeSensor to java.lang.String
> (Sensor: entity.id (java.lang.String)): no adapter known" which I think
> means that the sensor isn't avalable at the moment it is evaluated.   Ok
> that makes sense, but see the other examples I've tried below.....
>
> name: htsuite
> description: testserver
> location: localhost
> services:
>   - id: client_cluster
>     type: org.apache.brooklyn.entity.group.DynamicCluster
>     brooklyn.config:
>       cluster.initial.size: 2
>       dynamiccluster.memberspec:
>         $brooklyn:entitySpec:
>           type: htclienttemplate:1.4
>           name: client
>           customize.command: |
>             sudo mkdir
> $brooklyn:formatString("/Users/peterabramowitsch/manhattan/%s",
> *$brooklyn:sensor("entity.id
> <http://entity.id>") *)
>           brooklyn.config:
>             clientname: *$brooklyn:sensor("entity.id <http://entity.id>")
> *
>             rundir:
>               $brooklyn:formatString:
>                 - /Users/peterabramowitsch/manhattan/%s
>                 - *$brooklyn:sensor("entity.id <http://entity.id>")*
>             resturl:
>               $brooklyn:formatString:
>                 -
>
> http://127.0.0.1:8081/v1/applications/infocommons-composed/entities/%s/sensors
>                 - *$brooklyn:sensor("entity.id <http://entity.id>")*
>
> I have also tried
>    *$brooklyn:component("this","id")*
> *   $brooklyn:component("this").attributeWhenReady("id")*
> *   $brooklyn.id <http://brooklyn.id>*
>
> *   $brooklyn:config("id")*
>
> *   id*
>

Reply via email to