[openstack-dev] [congress] table with named parameters in rule's left side ?

Pospisil, Radek radek.pospisil at hp.com
Thu Jun 11 15:36:58 UTC 2015

Hi Tim,

Thanks for clarifications.
Ad 4) I saw dictionary for key-name tuples in action-execution API....

Ad 5) It is backup plan ☺ to have sufficient number of columns in the predeploy_modification table, so it won’t be readable, but it will work. My original intention is to use named parameters to give ability to specify more than one ‚property‘ in one action (e.g., predeploy_modificatino(,..‘add_object‘, type, p1=v1, p2=v2, p3=v3))



From: Tim Hinrichs [mailto:tim at styra.com]
Sent: Thursday, June 11, 2015 4:19 PM
To: OpenStack Development Mailing List (not for usage questions)
Subject: Re: [openstack-dev] [congress] table with named parameters in rule's left side ?

Hi Radek,
1. You can't use column references on any table except those created by a datasource, mainly because Congress doesn't know the name of the columns for those tables.  We've kicked around the idea of letting policy-writers declare the column names of any table, but it's trickier than it sounds.

2. Even if we solved (1), there's not much point in using column-references in the head (left-hand-side) of a rule because you always need to include all of the columns anyway.  That restriction is baked deeply into the semantics of the language: if you leave out a column in the head the size of the table is infinite.  The only benefit to column-references in the head would be enabling you to specify the columns in any order.

3. I've thought about tweaking the semantics of Datalog so that it includes both tuples and dictionaries.  But that is a major effort.

4. We don't actually allow column-references even within execute[ action(...)] because of (2).

5.  In your example, can you write it without the column references?  I don't see the predeploy_modify rule to understand why you need column references in the query.

 predeploy_modify(<uuid>,<uuid>,'add_property', 5, name="image”, value="<uuid>")

On Thu, Jun 11, 2015 at 6:44 AM Pospisil, Radek <radek.pospisil at hp.com<mailto:radek.pospisil at hp.com>> wrote:

Is it possible to have named parameters on rule’s left side, for example:

1.       predeploy_modify(eid,oid,"add_property",5, name=”image”, value=pvalue) :- …. Glancev2:images(name=pvalue,…)

2.       predeploy_modify(eid,oid,"add_object", 10, type=”monitoring”, port=8190, path=”/aa/bb”) :- ….

My Usecase is following – I want to use Congress to provide me list of ‘actions’ that I have to do on Murano environment prior it is deployed – for example:

•         I want to enforce/use specific image for given component(s) in environment, so I set corresponding property (example 1)

•         I want to add an object (monitoring) with properties to environment  (example 2)

Thus generally “I want to query for one rule with variable set/dictionary of arguments” – for example using simulation API:
$ openstack congress policy simulate test 'predeploy_modify()' '' action
Result will be
predeploy_modify(<uuid>,<uuid>,'add_property', 5, name="image”, value="<uuid>")
predeploy_modify(<uuid>,<uuid>,'add_object', 10, type="monitoring", port="…", path="…")

The problem is that if I do (as an example):

$  openstack congress policy rule create test "a(o,p,q=4) :- b(o),b(p)"
ERROR: openstack Syntax error for rule::Compiler found errors:Atom a(q=4) uses named parameters but the columns for table a have not been declared.
Atom a(q=4) uses named parameters but the columns for table a have not been declared. (HTTP 400) (Request-ID: req-b05683e6-766a-4be8-a238-5811eb6f7125)

So is it possible to use named parameters on not-declared tables?
I know that it is possible to do for “execute[ action(…) ] :- “, where positional and keyword/named set of parameters is passed to action-executor.


OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe<http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150611/c4fe677b/attachment.html>

More information about the OpenStack-dev mailing list