And if I try:

          enricher.targetValue: 
$brooklyn:sensor("cluster.first.entity").attributeWhenReady("host.name")

I get the error:

Error evaluating node (rethrowing) 
'$brooklyn:sensor("cluster.first.entity").attributeWhenReady("host.name")': 
java.lang.IllegalArgumentException: No such function 'attributeWhenReady' 
on sensor("cluster.first.entity")



From:   Mike Zaccardo <[email protected]>
To:     [email protected]
Date:   03/22/2017 04:31 PM
Subject:        Re: Trouble with YAML Transformer



>From the DSL spec [
https://docs.cloudsoft.io/blueprints/syntax-yaml-reference.html#dsl-commands

]:

* $brooklyn:sensor("sensor.name") returns the given sensor on the current
entity if found, or an untyped (Object) sensor;

* $brooklyn:sensor("com.acme.brooklyn.ContainingEntityClass", 
"sensor.name")
returns the strongly typed sensor defined in the given class

Based on that, it seemed to me that the first, single-argument value would
actually return the value of the sensor (the "object"), not the sensor
construct itself (the "class").  However, I tried updating your code and
ended up with an empty-valued sensor.

      brooklyn.enrichers:
        - type: org.apache.brooklyn.enricher.stock.Transformer
          brooklyn.config:
            enricher.sourceSensor: 
$brooklyn:sensor("cluster.first.entity")
            enricher.targetSensor: $brooklyn:sensor("cluster_first_host")
            enricher.targetValue:
              $brooklyn:formatString:
              - "%s"
              -
$brooklyn:sensor("cluster.first.entity").attributeWhenReady("host.name")

I'd like to kick the question to the rest of the community -- why does 
that
^ end up with an empty value? It should default to searching the current
entity, which is a `DynamicCluster`, which has a `cluster.first.entity`.

-Mike

On Wed, Mar 22, 2017 at 12:52 PM Graham Ashby <[email protected]>
wrote:

OK, Stupid mistake.
So, when I changed it to colon, I got the error:
2017-03-22 15:41:43,612 WARN  o.a.b.c.b.s.d.BrooklynDslInterpreter
[brooklyn-jetty-server-8081-qtp434786215-42]: Error evaluating node
(rethrowing) '$brooklyn:sensor("org.apache.brooklyn.api.entity.Entity",
"cluster.first.entity").attributeWhenReady("host.name")':
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Sensor
cluster.first.entity not found on class
org.apache.brooklyn.api.entity.Entity

So I changed the Cast:

          enricher.targetValue:
$brooklyn:sensor("org.apache.brooklyn.entity.group.AbstractGroup",
"cluster.first.entity").attributeWhenReady("host.name")

Now I get:

2017-03-22 15:43:50,909 WARN  o.a.b.c.b.s.d.BrooklynDslInterpreter
[brooklyn-jetty-server-8081-qtp434786215-2217]: Error evaluating node
(rethrowing)
'$brooklyn:sensor("org.apache.brooklyn.entity.group.AbstractGroup",
"cluster.first.entity").attributeWhenReady("host.name")':
java.lang.IllegalArgumentException: Not permitted to invoke function on
'class org.apache.brooklyn.core.sensor.BasicAttributeSensor' (outside
allowed package scope)

Thanks
G



From:   Mike Zaccardo <[email protected]>
To:     Brooklyn dev <[email protected]>
Date:   03/22/2017 03:30 PM
Subject:        Re: Trouble with YAML Transformer



Hi Graham,

In your `enricher.targetValue` -- `$brooklyn.sensor` should be
`$brooklyn:sensor`
(the dot replaced by a colon).

If that does not solve it, try providing the `enricher.targetValue` with
string, like so:

    brooklyn.enrichers:
      - type: org.apache.brooklyn.enricher.stock.Transformer
        brooklyn.config:
          enricher.sourceSensor: $brooklyn:sensor("cluster.first.entity")
          enricher.targetSensor: $brooklyn:sensor("cluster_first_host")
          enricher.targetValue:
            $brooklyn:formatString:
            - "%s"
            -
$brooklyn:sensor("org.apache.brooklyn.api.entity.Entity",
"cluster.first.entity").attributeWhenReady("
host.name")

I hope this helps.

Cheers,
Mike

On Wed, Mar 22, 2017 at 12:10 PM Graham Ashby <[email protected]>
wrote:

What I want is an attribute that I can include in a template.
I'm trying to get the host.name of the first entity in the cluster, so
what I've got is:

    brooklyn.enrichers:
      - type: org.apache.brooklyn.enricher.stock.Transformer
        brooklyn.config:
          enricher.sourceSensor: $brooklyn:sensor("cluster.first.entity")
          enricher.targetSensor: $brooklyn:sensor("cluster_first_host")
          enricher.targetValue:
$brooklyn.sensor("org.apache.brooklyn.api.entity.Entity",
"cluster.first.entity").attributeWhenReady("host.name")

But I get the literal value
"$brooklyn.sensor("org.apache.brooklyn.api.entity.Entity",
"cluster.first.entity").attributeWhenReady("host.name")"

So, what am I doing wrong?

Thanks
Graham

--

Mike Zaccardo

Senior Software Engineer

Skype: mike.cloudsoft

Twitter: @ItsMeMikeZ <https://twitter.com/ItsMeMikeZ> LinkedIn:
linkedin.com/in/mike-zaccardo
<https://www.linkedin.com/in/mike-zaccardo-aa3ab812>

[image: Cloudsoft Logo.jpg] <https://cloudsoft.io/>

Stay up to date with everything Cloudsoft:

[image: Twitter_Logo_White_On_Blue.png] <https://twitter.com/cloudsoft>
[image:
YouTube-social-icon_red_48px.png]
<https://www.youtube.com/channel/UCpbLhvXrYWz8B_osUX6rn0Q>




-- 

Mike Zaccardo

Senior Software Engineer

Skype: mike.cloudsoft

Twitter: @ItsMeMikeZ <https://twitter.com/ItsMeMikeZ> LinkedIn:
linkedin.com/in/mike-zaccardo
<https://www.linkedin.com/in/mike-zaccardo-aa3ab812>

[image: Cloudsoft Logo.jpg] <https://cloudsoft.io/>

Stay up to date with everything Cloudsoft:

[image: Twitter_Logo_White_On_Blue.png] <https://twitter.com/cloudsoft> 
[image:
YouTube-social-icon_red_48px.png]
<https://www.youtube.com/channel/UCpbLhvXrYWz8B_osUX6rn0Q>




Reply via email to