You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Richard Downer <ri...@apache.org> on 2017/07/17 08:54:50 UTC

Config keys with values that are entities

Hello all.

I have a catalog item for an entity type. This has a number of parameters,
including one parameter which is intended to hold a reference to an entity.
This works fine; I can see in the "config" pane of the entity this:

consul.serverReference Consul Server (bootstrap)

What I want to do is extract some of the referenced entity's attributes and
use them in my entity's blueprint. I'm struggling to find out how to do
that. While experimenting, I've ended up with this in my blueprint:

          consul.join1: $brooklyn:config("consul.serverReference")
          consul.join2: $brooklyn:entity(config("consul.serverReference"))
          consul.join3:
$brooklyn:component(config("consul.serverReference"))
          consul.join4:
$brooklyn:config("consul.serverReference").attributeWhenReady("entity.id")
          consul.join5:
$brooklyn:entity(config("consul.serverReference")).attributeWhenReady("
entity.id")
          consul.join6:
$brooklyn:component(config("consul.serverReference")).attributeWhenReady("
entity.id")

None of those are resolving. They appear in the config pane looking like
this:

consul.join1
{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"}
consul.join2
{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"}
consul.join3
{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"}
consul.join4
{"object":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"fnName":"attributeWhenReady","args":["
entity.id"]}
consul.join5
{"component":{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
entity.id"}
consul.join6
{"component":{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
entity.id"}

Is it possible to do what I want?

Thanks
Richard.

Re: Config keys with values that are entities

Posted by Richard Downer <ri...@apache.org>.
Thanks Duncan. That bit of the blueprint is working well - the server
cluster is able to come up normally, the first member being the bootstrap
server, and subsequent members able to detect the first and automatically
join the cluster, through the chained attributeWhenReady calls that you
noticed. So it does not look like that is a problem.

I should have been clearer and said that it is the sample-blueprint.yaml
that demonstrates the problem. It uses the catalog items (which can be
added with `br catalog add catalog`).

Thanks
Richard.


On 17 July 2017 at 13:03, Duncan Grant <du...@cloudsoftcorp.com>
wrote:

> Richard,
>
> I haven't quite got my head round what you're doing but I did notice that
> you were chaining attributeWhenReady calls
> https://github.com/rdowner/brooklyn-consul/blob/master/
> catalog/consul/consul-server-cluster.bom#L50
> which
> I don't think you can do as attributeWhenReady returns a
> BrooklynDSLDeferredSupplier.
>
> Could that be related?
>
> cheers
>
> Duncan
>
> On Mon, 17 Jul 2017 at 12:45 Richard Downer <ri...@apache.org> wrote:
>
> > Thanks Alex. Your blueprint is similar to mine, although consul.server in
> > my case is taken from the cluster.first.entity sensor of a
> DynamicCluster.
> > I've uploaded my code to https://github.com/rdowner/brooklyn-consul -
> can
> > you spot anything odd there?
> >
> > Thanks
> > Richard.
> >
> > On 17 July 2017 at 10:58, Alex Heneveld <alex.heneveld@cloudsoftcorp.com
> >
> > wrote:
> >
> > >
> > > Hi Richard-
> > >
> > > What you're doing looks fine.  Maybe something is wrong with the
> > > "consul.serverReference" value, or there is a bug around special
> > treatment
> > > of parameters.  The blueprint below shows what I think you're doing,
> > > several ways, and all work, both in bash and in the config view (IE
> fully
> > > resolved).  If "consul.serverReference" doesn't resolve I see the
> values
> > > you describe and I get a nice error in the Summary view when I try to
> use
> > > it ( Error resolving config consul.serverReference,
> > > $brooklyn:entity("MISSING"), ... NoSuchElementException: No entity
> > matching
> > > id).
> > >
> > > Can you share your blueprint?
> > >
> > > Best
> > > Alex
> > >
> > >
> > > location: localhost
> > > services:
> > > - type: org.apache.brooklyn.entity.software.base.
> VanillaSoftwareProcess
> > >   id: consul.server
> > >   launch.command: |
> > >       echo hello | nc -l 4321 &
> > >       echo $! > $PID_FILE
> > > - type: org.apache.brooklyn.entity.software.base.
> VanillaSoftwareProcess
> > >   launch.command: |
> > >       echo hello | nc -l 4322 &
> > >       echo $! > $PID_FILE
> > >   brooklyn.config:
> > >     consul.serverReference: $brooklyn:entity("consul.server")
> > >     shell.env:
> > >       consul_join0: $brooklyn:entity(config("consu
> > > l.serverReference")).attributeWhenReady("entity.id")
> > >       consul_join1: $brooklyn:entity(config("consu
> > > l.join1")).attributeWhenReady("entity.id")
> > >       consul_join2: $brooklyn:config("consul.join2")
> > >     consul.join1: $brooklyn:config("consul.serverReference")
> > >     consul.join2: $brooklyn:entity(config("consu
> > > l.serverReference")).attributeWhenReady("entity.id")
> > >
> > > END
> > >
> > >
> > >
> > >
> > > On 17/07/2017 09:54, Richard Downer wrote:
> > >
> > >> Hello all.
> > >>
> > >> I have a catalog item for an entity type. This has a number of
> > parameters,
> > >> including one parameter which is intended to hold a reference to an
> > >> entity.
> > >> This works fine; I can see in the "config" pane of the entity this:
> > >>
> > >> consul.serverReference Consul Server (bootstrap)
> > >>
> > >> What I want to do is extract some of the referenced entity's
> attributes
> > >> and
> > >> use them in my entity's blueprint. I'm struggling to find out how to
> do
> > >> that. While experimenting, I've ended up with this in my blueprint:
> > >>
> > >>            consul.join1: $brooklyn:config("consul.serverReference")
> > >>            consul.join2: $brooklyn:entity(config("consu
> > >> l.serverReference"))
> > >>            consul.join3:
> > >> $brooklyn:component(config("consul.serverReference"))
> > >>            consul.join4:
> > >> $brooklyn:config("consul.serverReference").attributeWhenReady("
> > entity.id
> > >> ")
> > >>            consul.join5:
> > >> $brooklyn:entity(config("consul.serverReference")).
> attributeWhenReady("
> > >> entity.id")
> > >>            consul.join6:
> > >> $brooklyn:component(config("consul.serverReference")).attrib
> > >> uteWhenReady("
> > >> entity.id")
> > >>
> > >> None of those are resolving. They appear in the config pane looking
> like
> > >> this:
> > >>
> > >> consul.join1
> > >> {"component":{"componentId":"","componentIdSupplier":null,"s
> > >> copeComponent":null,"scope":"THIS"},"keyName":"consul.
> serverReference"}
> > >> consul.join2
> > >> {"componentId":null,"componentIdSupplier":{"component":{"
> > >> componentId":"","componentIdSupplier":null,"scopeComponent":
> > >> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
> > >> opeComponent":null,"scope":"GLOBAL"}
> > >> consul.join3
> > >> {"componentId":null,"componentIdSupplier":{"component":{"
> > >> componentId":"","componentIdSupplier":null,"scopeComponent":
> > >> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
> > >> opeComponent":null,"scope":"GLOBAL"}
> > >> consul.join4
> > >> {"object":{"component":{"componentId":"","componentIdSupplie
> > >> r":null,"scopeComponent":null,"scope":"THIS"},"keyName":"
> > >> consul.serverReference"},"fnName":"attributeWhenReady","args":["
> > >> entity.id"]}
> > >> consul.join5
> > >> {"component":{"componentId":null,"componentIdSupplier":{"com
> > >> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
> > >> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
> > >> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> > >> entity.id"}
> > >> consul.join6
> > >> {"component":{"componentId":null,"componentIdSupplier":{"com
> > >> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
> > >> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
> > >> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> > >> entity.id"}
> > >>
> > >> Is it possible to do what I want?
> > >>
> > >> Thanks
> > >> Richard.
> > >>
> > >>
> > >
> >
>

Re: Config keys with values that are entities

Posted by Duncan Grant <du...@cloudsoftcorp.com>.
Richard,

I haven't quite got my head round what you're doing but I did notice that
you were chaining attributeWhenReady calls
https://github.com/rdowner/brooklyn-consul/blob/master/catalog/consul/consul-server-cluster.bom#L50
which
I don't think you can do as attributeWhenReady returns a
BrooklynDSLDeferredSupplier.

Could that be related?

cheers

Duncan

On Mon, 17 Jul 2017 at 12:45 Richard Downer <ri...@apache.org> wrote:

> Thanks Alex. Your blueprint is similar to mine, although consul.server in
> my case is taken from the cluster.first.entity sensor of a DynamicCluster.
> I've uploaded my code to https://github.com/rdowner/brooklyn-consul - can
> you spot anything odd there?
>
> Thanks
> Richard.
>
> On 17 July 2017 at 10:58, Alex Heneveld <al...@cloudsoftcorp.com>
> wrote:
>
> >
> > Hi Richard-
> >
> > What you're doing looks fine.  Maybe something is wrong with the
> > "consul.serverReference" value, or there is a bug around special
> treatment
> > of parameters.  The blueprint below shows what I think you're doing,
> > several ways, and all work, both in bash and in the config view (IE fully
> > resolved).  If "consul.serverReference" doesn't resolve I see the values
> > you describe and I get a nice error in the Summary view when I try to use
> > it ( Error resolving config consul.serverReference,
> > $brooklyn:entity("MISSING"), ... NoSuchElementException: No entity
> matching
> > id).
> >
> > Can you share your blueprint?
> >
> > Best
> > Alex
> >
> >
> > location: localhost
> > services:
> > - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
> >   id: consul.server
> >   launch.command: |
> >       echo hello | nc -l 4321 &
> >       echo $! > $PID_FILE
> > - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
> >   launch.command: |
> >       echo hello | nc -l 4322 &
> >       echo $! > $PID_FILE
> >   brooklyn.config:
> >     consul.serverReference: $brooklyn:entity("consul.server")
> >     shell.env:
> >       consul_join0: $brooklyn:entity(config("consu
> > l.serverReference")).attributeWhenReady("entity.id")
> >       consul_join1: $brooklyn:entity(config("consu
> > l.join1")).attributeWhenReady("entity.id")
> >       consul_join2: $brooklyn:config("consul.join2")
> >     consul.join1: $brooklyn:config("consul.serverReference")
> >     consul.join2: $brooklyn:entity(config("consu
> > l.serverReference")).attributeWhenReady("entity.id")
> >
> > END
> >
> >
> >
> >
> > On 17/07/2017 09:54, Richard Downer wrote:
> >
> >> Hello all.
> >>
> >> I have a catalog item for an entity type. This has a number of
> parameters,
> >> including one parameter which is intended to hold a reference to an
> >> entity.
> >> This works fine; I can see in the "config" pane of the entity this:
> >>
> >> consul.serverReference Consul Server (bootstrap)
> >>
> >> What I want to do is extract some of the referenced entity's attributes
> >> and
> >> use them in my entity's blueprint. I'm struggling to find out how to do
> >> that. While experimenting, I've ended up with this in my blueprint:
> >>
> >>            consul.join1: $brooklyn:config("consul.serverReference")
> >>            consul.join2: $brooklyn:entity(config("consu
> >> l.serverReference"))
> >>            consul.join3:
> >> $brooklyn:component(config("consul.serverReference"))
> >>            consul.join4:
> >> $brooklyn:config("consul.serverReference").attributeWhenReady("
> entity.id
> >> ")
> >>            consul.join5:
> >> $brooklyn:entity(config("consul.serverReference")).attributeWhenReady("
> >> entity.id")
> >>            consul.join6:
> >> $brooklyn:component(config("consul.serverReference")).attrib
> >> uteWhenReady("
> >> entity.id")
> >>
> >> None of those are resolving. They appear in the config pane looking like
> >> this:
> >>
> >> consul.join1
> >> {"component":{"componentId":"","componentIdSupplier":null,"s
> >> copeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"}
> >> consul.join2
> >> {"componentId":null,"componentIdSupplier":{"component":{"
> >> componentId":"","componentIdSupplier":null,"scopeComponent":
> >> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
> >> opeComponent":null,"scope":"GLOBAL"}
> >> consul.join3
> >> {"componentId":null,"componentIdSupplier":{"component":{"
> >> componentId":"","componentIdSupplier":null,"scopeComponent":
> >> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
> >> opeComponent":null,"scope":"GLOBAL"}
> >> consul.join4
> >> {"object":{"component":{"componentId":"","componentIdSupplie
> >> r":null,"scopeComponent":null,"scope":"THIS"},"keyName":"
> >> consul.serverReference"},"fnName":"attributeWhenReady","args":["
> >> entity.id"]}
> >> consul.join5
> >> {"component":{"componentId":null,"componentIdSupplier":{"com
> >> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
> >> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
> >> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> >> entity.id"}
> >> consul.join6
> >> {"component":{"componentId":null,"componentIdSupplier":{"com
> >> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
> >> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
> >> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> >> entity.id"}
> >>
> >> Is it possible to do what I want?
> >>
> >> Thanks
> >> Richard.
> >>
> >>
> >
>

Re: Config keys with values that are entities

Posted by Alex Heneveld <al...@cloudsoftcorp.com>.
Hi Richard-

I've found the problem:  you're not specifying a type for 
`consul.serverReference`.  If a parameter is defined without any type, 
it defaults to a string (at BasicSpecParameter.inferType), causing a 
coercion exception when it tries to `config().get` the key.  The 
coercion problem is shown in the tasks view when start fails.

Try adding `type: org.apache.brooklyn.api.entity.Entity` to that 
parameter definition.

Best
Alex


On 17/07/2017 12:45, Richard Downer wrote:
> Thanks Alex. Your blueprint is similar to mine, although consul.server in
> my case is taken from the cluster.first.entity sensor of a DynamicCluster.
> I've uploaded my code to https://github.com/rdowner/brooklyn-consul - can
> you spot anything odd there?
>
> Thanks
> Richard.
>
> On 17 July 2017 at 10:58, Alex Heneveld <al...@cloudsoftcorp.com>
> wrote:
>
>> Hi Richard-
>>
>> What you're doing looks fine.  Maybe something is wrong with the
>> "consul.serverReference" value, or there is a bug around special treatment
>> of parameters.  The blueprint below shows what I think you're doing,
>> several ways, and all work, both in bash and in the config view (IE fully
>> resolved).  If "consul.serverReference" doesn't resolve I see the values
>> you describe and I get a nice error in the Summary view when I try to use
>> it ( Error resolving config consul.serverReference,
>> $brooklyn:entity("MISSING"), ... NoSuchElementException: No entity matching
>> id).
>>
>> Can you share your blueprint?
>>
>> Best
>> Alex
>>
>>
>> location: localhost
>> services:
>> - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
>>    id: consul.server
>>    launch.command: |
>>        echo hello | nc -l 4321 &
>>        echo $! > $PID_FILE
>> - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
>>    launch.command: |
>>        echo hello | nc -l 4322 &
>>        echo $! > $PID_FILE
>>    brooklyn.config:
>>      consul.serverReference: $brooklyn:entity("consul.server")
>>      shell.env:
>>        consul_join0: $brooklyn:entity(config("consu
>> l.serverReference")).attributeWhenReady("entity.id")
>>        consul_join1: $brooklyn:entity(config("consu
>> l.join1")).attributeWhenReady("entity.id")
>>        consul_join2: $brooklyn:config("consul.join2")
>>      consul.join1: $brooklyn:config("consul.serverReference")
>>      consul.join2: $brooklyn:entity(config("consu
>> l.serverReference")).attributeWhenReady("entity.id")
>>
>> END
>>
>>
>>
>>
>> On 17/07/2017 09:54, Richard Downer wrote:
>>
>>> Hello all.
>>>
>>> I have a catalog item for an entity type. This has a number of parameters,
>>> including one parameter which is intended to hold a reference to an
>>> entity.
>>> This works fine; I can see in the "config" pane of the entity this:
>>>
>>> consul.serverReference Consul Server (bootstrap)
>>>
>>> What I want to do is extract some of the referenced entity's attributes
>>> and
>>> use them in my entity's blueprint. I'm struggling to find out how to do
>>> that. While experimenting, I've ended up with this in my blueprint:
>>>
>>>             consul.join1: $brooklyn:config("consul.serverReference")
>>>             consul.join2: $brooklyn:entity(config("consu
>>> l.serverReference"))
>>>             consul.join3:
>>> $brooklyn:component(config("consul.serverReference"))
>>>             consul.join4:
>>> $brooklyn:config("consul.serverReference").attributeWhenReady("entity.id
>>> ")
>>>             consul.join5:
>>> $brooklyn:entity(config("consul.serverReference")).attributeWhenReady("
>>> entity.id")
>>>             consul.join6:
>>> $brooklyn:component(config("consul.serverReference")).attrib
>>> uteWhenReady("
>>> entity.id")
>>>
>>> None of those are resolving. They appear in the config pane looking like
>>> this:
>>>
>>> consul.join1
>>> {"component":{"componentId":"","componentIdSupplier":null,"s
>>> copeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"}
>>> consul.join2
>>> {"componentId":null,"componentIdSupplier":{"component":{"
>>> componentId":"","componentIdSupplier":null,"scopeComponent":
>>> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
>>> opeComponent":null,"scope":"GLOBAL"}
>>> consul.join3
>>> {"componentId":null,"componentIdSupplier":{"component":{"
>>> componentId":"","componentIdSupplier":null,"scopeComponent":
>>> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
>>> opeComponent":null,"scope":"GLOBAL"}
>>> consul.join4
>>> {"object":{"component":{"componentId":"","componentIdSupplie
>>> r":null,"scopeComponent":null,"scope":"THIS"},"keyName":"
>>> consul.serverReference"},"fnName":"attributeWhenReady","args":["
>>> entity.id"]}
>>> consul.join5
>>> {"component":{"componentId":null,"componentIdSupplier":{"com
>>> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
>>> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
>>> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
>>> entity.id"}
>>> consul.join6
>>> {"component":{"componentId":null,"componentIdSupplier":{"com
>>> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
>>> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
>>> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
>>> entity.id"}
>>>
>>> Is it possible to do what I want?
>>>
>>> Thanks
>>> Richard.
>>>
>>>


Re: Config keys with values that are entities

Posted by Richard Downer <ri...@apache.org>.
Thanks Alex. Your blueprint is similar to mine, although consul.server in
my case is taken from the cluster.first.entity sensor of a DynamicCluster.
I've uploaded my code to https://github.com/rdowner/brooklyn-consul - can
you spot anything odd there?

Thanks
Richard.

On 17 July 2017 at 10:58, Alex Heneveld <al...@cloudsoftcorp.com>
wrote:

>
> Hi Richard-
>
> What you're doing looks fine.  Maybe something is wrong with the
> "consul.serverReference" value, or there is a bug around special treatment
> of parameters.  The blueprint below shows what I think you're doing,
> several ways, and all work, both in bash and in the config view (IE fully
> resolved).  If "consul.serverReference" doesn't resolve I see the values
> you describe and I get a nice error in the Summary view when I try to use
> it ( Error resolving config consul.serverReference,
> $brooklyn:entity("MISSING"), ... NoSuchElementException: No entity matching
> id).
>
> Can you share your blueprint?
>
> Best
> Alex
>
>
> location: localhost
> services:
> - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
>   id: consul.server
>   launch.command: |
>       echo hello | nc -l 4321 &
>       echo $! > $PID_FILE
> - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
>   launch.command: |
>       echo hello | nc -l 4322 &
>       echo $! > $PID_FILE
>   brooklyn.config:
>     consul.serverReference: $brooklyn:entity("consul.server")
>     shell.env:
>       consul_join0: $brooklyn:entity(config("consu
> l.serverReference")).attributeWhenReady("entity.id")
>       consul_join1: $brooklyn:entity(config("consu
> l.join1")).attributeWhenReady("entity.id")
>       consul_join2: $brooklyn:config("consul.join2")
>     consul.join1: $brooklyn:config("consul.serverReference")
>     consul.join2: $brooklyn:entity(config("consu
> l.serverReference")).attributeWhenReady("entity.id")
>
> END
>
>
>
>
> On 17/07/2017 09:54, Richard Downer wrote:
>
>> Hello all.
>>
>> I have a catalog item for an entity type. This has a number of parameters,
>> including one parameter which is intended to hold a reference to an
>> entity.
>> This works fine; I can see in the "config" pane of the entity this:
>>
>> consul.serverReference Consul Server (bootstrap)
>>
>> What I want to do is extract some of the referenced entity's attributes
>> and
>> use them in my entity's blueprint. I'm struggling to find out how to do
>> that. While experimenting, I've ended up with this in my blueprint:
>>
>>            consul.join1: $brooklyn:config("consul.serverReference")
>>            consul.join2: $brooklyn:entity(config("consu
>> l.serverReference"))
>>            consul.join3:
>> $brooklyn:component(config("consul.serverReference"))
>>            consul.join4:
>> $brooklyn:config("consul.serverReference").attributeWhenReady("entity.id
>> ")
>>            consul.join5:
>> $brooklyn:entity(config("consul.serverReference")).attributeWhenReady("
>> entity.id")
>>            consul.join6:
>> $brooklyn:component(config("consul.serverReference")).attrib
>> uteWhenReady("
>> entity.id")
>>
>> None of those are resolving. They appear in the config pane looking like
>> this:
>>
>> consul.join1
>> {"component":{"componentId":"","componentIdSupplier":null,"s
>> copeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"}
>> consul.join2
>> {"componentId":null,"componentIdSupplier":{"component":{"
>> componentId":"","componentIdSupplier":null,"scopeComponent":
>> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
>> opeComponent":null,"scope":"GLOBAL"}
>> consul.join3
>> {"componentId":null,"componentIdSupplier":{"component":{"
>> componentId":"","componentIdSupplier":null,"scopeComponent":
>> null,"scope":"THIS"},"keyName":"consul.serverReference"},"sc
>> opeComponent":null,"scope":"GLOBAL"}
>> consul.join4
>> {"object":{"component":{"componentId":"","componentIdSupplie
>> r":null,"scopeComponent":null,"scope":"THIS"},"keyName":"
>> consul.serverReference"},"fnName":"attributeWhenReady","args":["
>> entity.id"]}
>> consul.join5
>> {"component":{"componentId":null,"componentIdSupplier":{"com
>> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
>> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
>> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
>> entity.id"}
>> consul.join6
>> {"component":{"componentId":null,"componentIdSupplier":{"com
>> ponent":{"componentId":"","componentIdSupplier":null,"scopeC
>> omponent":null,"scope":"THIS"},"keyName":"consul.serverRefer
>> ence"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
>> entity.id"}
>>
>> Is it possible to do what I want?
>>
>> Thanks
>> Richard.
>>
>>
>

Re: Config keys with values that are entities

Posted by Alex Heneveld <al...@cloudsoftcorp.com>.
Hi Richard-

What you're doing looks fine.  Maybe something is wrong with the 
"consul.serverReference" value, or there is a bug around special 
treatment of parameters.  The blueprint below shows what I think you're 
doing, several ways, and all work, both in bash and in the config view 
(IE fully resolved).  If "consul.serverReference" doesn't resolve I see 
the values you describe and I get a nice error in the Summary view when 
I try to use it ( Error resolving config consul.serverReference, 
$brooklyn:entity("MISSING"), ... NoSuchElementException: No entity 
matching id).

Can you share your blueprint?

Best
Alex


location: localhost
services:
- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
   id: consul.server
   launch.command: |
       echo hello | nc -l 4321 &
       echo $! > $PID_FILE
- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
   launch.command: |
       echo hello | nc -l 4322 &
       echo $! > $PID_FILE
   brooklyn.config:
     consul.serverReference: $brooklyn:entity("consul.server")
     shell.env:
       consul_join0: 
$brooklyn:entity(config("consul.serverReference")).attributeWhenReady("entity.id")
       consul_join1: 
$brooklyn:entity(config("consul.join1")).attributeWhenReady("entity.id")
       consul_join2: $brooklyn:config("consul.join2")
     consul.join1: $brooklyn:config("consul.serverReference")
     consul.join2: 
$brooklyn:entity(config("consul.serverReference")).attributeWhenReady("entity.id")

END



On 17/07/2017 09:54, Richard Downer wrote:
> Hello all.
>
> I have a catalog item for an entity type. This has a number of parameters,
> including one parameter which is intended to hold a reference to an entity.
> This works fine; I can see in the "config" pane of the entity this:
>
> consul.serverReference Consul Server (bootstrap)
>
> What I want to do is extract some of the referenced entity's attributes and
> use them in my entity's blueprint. I'm struggling to find out how to do
> that. While experimenting, I've ended up with this in my blueprint:
>
>            consul.join1: $brooklyn:config("consul.serverReference")
>            consul.join2: $brooklyn:entity(config("consul.serverReference"))
>            consul.join3:
> $brooklyn:component(config("consul.serverReference"))
>            consul.join4:
> $brooklyn:config("consul.serverReference").attributeWhenReady("entity.id")
>            consul.join5:
> $brooklyn:entity(config("consul.serverReference")).attributeWhenReady("
> entity.id")
>            consul.join6:
> $brooklyn:component(config("consul.serverReference")).attributeWhenReady("
> entity.id")
>
> None of those are resolving. They appear in the config pane looking like
> this:
>
> consul.join1
> {"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"}
> consul.join2
> {"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"}
> consul.join3
> {"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"}
> consul.join4
> {"object":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"fnName":"attributeWhenReady","args":["
> entity.id"]}
> consul.join5
> {"component":{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> entity.id"}
> consul.join6
> {"component":{"componentId":null,"componentIdSupplier":{"component":{"componentId":"","componentIdSupplier":null,"scopeComponent":null,"scope":"THIS"},"keyName":"consul.serverReference"},"scopeComponent":null,"scope":"GLOBAL"},"sensorName":"
> entity.id"}
>
> Is it possible to do what I want?
>
> Thanks
> Richard.
>