You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ace.apache.org by Daan Veldhof <da...@gmail.com> on 2015/10/22 16:59:29 UTC

Creating association based on multiple tags

Hi all,

I want to create a distribution2target where the leftEndpoint = (name=rand)
and the rightEndpoint = (target.tag1 = foo)&(target.tag2 = bar). From what
I understand the filtering works with an LDAP filter. So I tried to create
a distribution2target using the REST API. I send a POST to
/client/work/{id}/distribution2target and in the body is this
{
  attributes : {
    "leftEndpoint" : "(name=rand)",
    "rightEndpoint" : "(&(target.tag1=foo)(target.tag2=bar))"
    "leftCardinality" : 5,
    "rightCardinality" : 100
  }
  tags: {}
}

This does not create the association I want. I've already tried to replace
the left- and rightendpoint with "left" and "right" respectively.

Is this even possible?

-Regards
Daan Veldhof
<https://www.google.nl/search?q=respectively&spell=1&sa=X&ved=0CBsQvwUoAGoVChMItKn82KvWyAIVR-0UCh2nVQWE>

Re: Creating association based on multiple tags

Posted by Jan Willem Janssen <ja...@luminis.eu>.
> On 27 Oct 2015, at 16:14, Daan Veldhof <da...@gmail.com> wrote:
> 
> And how do I put that there using the REST api?
> I already tried:
> 
> attributes : {
> ..
>  "rightCardinality" : "n"
> ..
> }
> 
> and replaced "n" with "N", 'n' and 'N'
> 
> It gives me error 400
> 
> Could not add entity of type distribution2target with data:
> RepositoryValueObject with attributes
> [{rightEndpoint=(&amp;(target.role=producer)(target.cpu_arch=armeabi)),
> leftEndpoint=(name=producer_armeabi), rightCardinality=N,
> leftCardinality=1}] and with tags [{}]

It appears that this currently only works for the Gogo shell. I’ve created
ACE-523 (see [1]) to fix this. Will push a fix for it soon.


1. https://issues.apache.org/jira/browse/ACE-523

--
Met vriendelijke groeten | Kind regards

Jan Willem Janssen | Software Architect
+31 631 765 814

My world is revolving around INAETICS and Amdatu

Luminis Technologies B.V.
Churchillplein 1
7314 BZ   Apeldoorn
+31 88 586 46 00

http://www.luminis-technologies.com
http://www.luminis.eu

KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01


Re: Creating association based on multiple tags

Posted by Daan Veldhof <da...@gmail.com>.
2015-10-27 14:44 GMT+01:00 Jan Willem Janssen <ja...@luminis.eu>
:


> Order is never considered when applying JSON data in ACE, so not sure that
> is the root cause of your issue. I’ve created several distribution-target
> associations with the attributes in varying order and they always produce
> the same result.
>
>
I also thought that, but it works for now.
Did you try it with the REST API or the GoGo shell?


>
> The convention in ACE is that if you want to associate a distribution to
> *any* target that you use a right cardinality of ’N’ (without quotes).
>
>
And how do I put that there using the REST api?
I already tried:

attributes : {
 ..
  "rightCardinality" : "n"
 ..
}

and replaced "n" with "N", 'n' and 'N'

It gives me error 400

Could not add entity of type distribution2target with data:
RepositoryValueObject with attributes
[{rightEndpoint=(&amp;(target.role=producer)(target.cpu_arch=armeabi)),
leftEndpoint=(name=producer_armeabi), rightCardinality=N,
leftCardinality=1}] and with tags [{}]

Regards
Daan Veldhof

Re: Creating association based on multiple tags

Posted by Jan Willem Janssen <ja...@luminis.eu>.
> On 27 Oct 2015, at 11:35, Daan Veldhof <da...@gmail.com> wrote:
> 
> 2015-10-24 20:27 GMT+02:00 Marcel Offermans <ma...@luminis.nl>:
> 
>> On 23 October 2015 at 07:16:02, Jan Willem Janssen (
>> janwillem.janssen@luminis.eu(mailto:janwillem.janssen@luminis.eu)) wrote:
>> 
>>> Ergo: still not sure that the ‘target.’ prefix is necessary unless your
>>> tags actually use them in their names.
>> 
>> FYI, it is definitely wrong to use the “target.” prefix unless those tags
>> are actually prefixed with “target.”.
>> 
>> Greetings, Marcel
>> 
>> 
> Those tags are prefixed with "target." because that's how ACE works. When a
> target is started (deployment_admin is installed in the framework) it first
> sends the FRAMEWORK_STARTED auditlog and then the TARGETPROPERTIES_SET with
> the tags I want to give to the target. ACE automatically prefixes these
> tags with "target.”

Ah, you did not tell that you’ve been using the TARGETPROPERTIES_SET event
to push tags to the server. As [1] states in the Usage section (emphasis
mine):

  Make sure you always write the full set of properties, as any old ones
  will be erased. The keys of the properties you set will end up as tags,
  prefixed with **"target."** to distinguish them from **other** tags that
  might be set manually.

So, in that case you need to prefix your “custom” tags with “target.” in
the association filter. I’ve tried this with a local project (using either
the Gogo shell or the REST API directly) and this works fine.

>> On 23 October 2015 at 07:16:02, Jan Willem Janssen (
> janwillem.janssen@luminis.eu(mailto:janwillem.janssen@luminis.eu)) wrote:
>> I’ve used the following gogo script to test creating a feature,
> distribution
>> and a target with two tags along with the various associations using
> filters.
>> […]
> 
> Apparently when I change the order of the attributes in the REST call it
> works, so this fixed the issue:
> 
> {
>  attributes : {
>   "leftCardinality" : 1,
>   "leftEndpoint" : "(name=rand)",
>   "rightCardinality" : 100
>   "rightEndpoint" : "(&(target.tag1=foo)(target.tag2=bar)"
>  }
>  tags: {}
> }

Order is never considered when applying JSON data in ACE, so not sure that
is the root cause of your issue. I’ve created several distribution-target
associations with the attributes in varying order and they always produce
the same result.

>> Note that I didn’t set any cardinality values, since they default to 1.
> Why
>> are you using custom cardinality numbers?
> 
> When I leave out the cardinality values, they don't show up if I get the
> distribution2target (client/{WORKID}/distribution2target/{ID})
> I'm using custom cardinality values so multiple targets can get the same
> distribution. I already removed the leftcardinality.

The convention in ACE is that if you want to associate a distribution to
*any* target that you use a right cardinality of ’N’ (without quotes).


1. https://cwiki.apache.org/confluence/display/ACE/Target+Attributes+analysis

--
Met vriendelijke groeten | Kind regards

Jan Willem Janssen | Software Architect
+31 631 765 814

My world is revolving around INAETICS and Amdatu

Luminis Technologies B.V.
Churchillplein 1
7314 BZ   Apeldoorn
+31 88 586 46 00

http://www.luminis-technologies.com
http://www.luminis.eu

KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01


Re: Creating association based on multiple tags

Posted by Daan Veldhof <da...@gmail.com>.
2015-10-24 20:27 GMT+02:00 Marcel Offermans <ma...@luminis.nl>:

> On 23 October 2015 at 07:16:02, Jan Willem Janssen (
> janwillem.janssen@luminis.eu(mailto:janwillem.janssen@luminis.eu)) wrote:
>
> > Ergo: still not sure that the ‘target.’ prefix is necessary unless your
> > tags actually use them in their names.
>
> FYI, it is definitely wrong to use the “target.” prefix unless those tags
> are actually prefixed with “target.”.
>
> Greetings, Marcel
>
>
Those tags are prefixed with "target." because that's how ACE works. When a
target is started (deployment_admin is installed in the framework) it first
sends the FRAMEWORK_STARTED auditlog and then the TARGETPROPERTIES_SET with
the tags I want to give to the target. ACE automatically prefixes these
tags with "target."

> On 23 October 2015 at 07:16:02, Jan Willem Janssen (
janwillem.janssen@luminis.eu(mailto:janwillem.janssen@luminis.eu)) wrote:
> I’ve used the following gogo script to test creating a feature,
distribution
> and a target with two tags along with the various associations using
filters.
>
>   w=(cw)
>   $w cf 'feature1'
>   $w cd 'dist1'
>   $w cf2d '(name=feature1)' '(name=dist*)'
>  ($w ct [id='target1'] [foo=bar qux=quu]) setautoapprove true
>   $w cd2t '(name=dist1)' '(&(foo=bar)(qux=*))'
>   $w commit
>   rw $w
>
> In my environment, my target is correctly linked to the distribution based
> on its tags.

I tried the GoGo shell way and that actually worked.
I set up all the artifacts, artifact2features, features,
feature2distributions and distributions using the REST API and set the
distribution2targets with the GoGo shell and that worked.
But I want to be able to remotely remove, add or change the
distribution2target, so using the REST API.


Apparently when I change the order of the attributes in the REST call it
works, so this fixed the issue:

{
  attributes : {
   "leftCardinality" : 1,
   "leftEndpoint" : "(name=rand)",
   "rightCardinality" : 100
   "rightEndpoint" : "(&(target.tag1=foo)(target.tag2=bar)"
  }
  tags: {}
}


> Note that I didn’t set any cardinality values, since they default to 1.
Why
> are you using custom cardinality numbers?

When I leave out the cardinality values, they don't show up if I get the
distribution2target (client/{WORKID}/distribution2target/{ID})
I'm using custom cardinality values so multiple targets can get the same
distribution. I already removed the leftcardinality.

Regards,
Daan

Re: Creating association based on multiple tags

Posted by Marcel Offermans <ma...@luminis.nl>.
On 23 October 2015 at 07:16:02, Jan Willem Janssen (janwillem.janssen@luminis.eu(mailto:janwillem.janssen@luminis.eu)) wrote:

> Ergo: still not sure that the ‘target.’ prefix is necessary unless your  
> tags actually use them in their names.  

FYI, it is definitely wrong to use the “target.” prefix unless those tags are actually prefixed with “target.”.

Greetings, Marcel


Re: Creating association based on multiple tags

Posted by Jan Willem Janssen <ja...@luminis.eu>.
> On 23 Oct 2015, at 09:31, Daan Veldhof <da...@gmail.com> wrote:
> 
> Changed my attributes so it only filters on one tag and it works with the
> 'target' prefix.
> 
> {
>  attributes : {
>    "leftEndpoint" : "(name=rand)",
>    "rightEndpoint" : "(target.tag1=foo)"
>    "leftCardinality" : 1,
>    "rightCardinality" : 100
>  }
>  tags: {}
> }
> 
> For some reason the "&" doesn't seem to work. Am I missing something?
> 
> BTW, when I create the distribution2target the targets aren't known by ACE,
> I add them afterwards.
> 

I’ve used the following gogo script to test creating a feature, distribution
and a target with two tags along with the various associations using filters.

  w=(cw)
  $w cf 'feature1'
  $w cd 'dist1'
  $w cf2d '(name=feature1)' '(name=dist*)'
  ($w ct [id='target1'] [foo=bar qux=quu]) setautoapprove true
  $w cd2t '(name=dist1)' '(&(foo=bar)(qux=*))'
  $w commit
  rw $w

In my environment, my target is correctly linked to the distribution based
on its tags.

Ergo: still not sure that the ‘target.’ prefix is necessary unless your
tags actually use them in their names.

Note that I didn’t set any cardinality values, since they default to 1. Why
are you using custom cardinality numbers?

--
Met vriendelijke groeten | Kind regards

Jan Willem Janssen | Software Architect
+31 631 765 814

My world is revolving around INAETICS and Amdatu

Luminis Technologies B.V.
Churchillplein 1
7314 BZ   Apeldoorn
+31 88 586 46 00

http://www.luminis-technologies.com
http://www.luminis.eu

KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01


Re: Creating association based on multiple tags

Posted by Daan Veldhof <da...@gmail.com>.
2015-10-22 17:39 GMT+02:00 Jan Willem Janssen <ja...@luminis.eu>
:

>
> > On 22 Oct 2015, at 16:59, Daan Veldhof <da...@gmail.com> wrote:
> >
> > I want to create a distribution2target where the leftEndpoint =
> (name=rand)
> > and the rightEndpoint = (target.tag1 = foo)&(target.tag2 = bar). From
> what
> > I understand the filtering works with an LDAP filter. So I tried to
> create
> > a distribution2target using the REST API. I send a POST to
> > /client/work/{id}/distribution2target and in the body is this
> > {
> >  attributes : {
> >    "leftEndpoint" : "(name=rand)",
> >    "rightEndpoint" : "(&(target.tag1=foo)(target.tag2=bar))"
> >    "leftCardinality" : 5,
> >    "rightCardinality" : 100
> >  }
> >  tags: {}
> > }
>
> You’re trying to create an association that should match up to 5
> distributions and up to 100 targets, which is valid, but a little bit
> strange
> given that you specify a distribution that is named exactly to “rand”.
>
> Anyway, you might want to take a look at your rightEndpoint filter, IIRC it
> is not necessary to prefix it with `target.`...
>


Changed my attributes so it only filters on one tag and it works with the
'target' prefix.

{
  attributes : {
    "leftEndpoint" : "(name=rand)",
    "rightEndpoint" : "(target.tag1=foo)"
    "leftCardinality" : 1,
    "rightCardinality" : 100
  }
  tags: {}
}

For some reason the "&" doesn't seem to work. Am I missing something?

BTW, when I create the distribution2target the targets aren't known by ACE,
I add them afterwards.

Regards
Daan Veldhof

Re: Creating association based on multiple tags

Posted by Jan Willem Janssen <ja...@luminis.eu>.
> On 22 Oct 2015, at 16:59, Daan Veldhof <da...@gmail.com> wrote:
> 
> I want to create a distribution2target where the leftEndpoint = (name=rand)
> and the rightEndpoint = (target.tag1 = foo)&(target.tag2 = bar). From what
> I understand the filtering works with an LDAP filter. So I tried to create
> a distribution2target using the REST API. I send a POST to
> /client/work/{id}/distribution2target and in the body is this
> {
>  attributes : {
>    "leftEndpoint" : "(name=rand)",
>    "rightEndpoint" : "(&(target.tag1=foo)(target.tag2=bar))"
>    "leftCardinality" : 5,
>    "rightCardinality" : 100
>  }
>  tags: {}
> }

You’re trying to create an association that should match up to 5
distributions and up to 100 targets, which is valid, but a little bit strange
given that you specify a distribution that is named exactly to “rand”.

Anyway, you might want to take a look at your rightEndpoint filter, IIRC it
is not necessary to prefix it with `target.`...

--
Met vriendelijke groeten | Kind regards

Jan Willem Janssen | Software Architect
+31 631 765 814

My world is revolving around INAETICS and Amdatu

Luminis Technologies B.V.
Churchillplein 1
7314 BZ   Apeldoorn
+31 88 586 46 00

http://www.luminis-technologies.com
http://www.luminis.eu

KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01