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

2015-06-11 Thread Tim Hinrichs
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)

Tim



On Thu, Jun 11, 2015 at 6:44 AM Pospisil, Radek radek.pospi...@hp.com
wrote:

  Hello,



 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.





   Regards,



 Radek

 __
 OpenStack Development Mailing List (not for usage questions)
 Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
 http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-06-11 Thread Pospisil, Radek
Hello,

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.


  Regards,

Radek
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-06-11 Thread Pospisil, Radek
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))

  Regards,

Radek

From: Tim Hinrichs [mailto:t...@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)
Tim



On Thu, Jun 11, 2015 at 6:44 AM Pospisil, Radek 
radek.pospi...@hp.commailto:radek.pospi...@hp.com wrote:
Hello,

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.


  Regards,

Radek
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: 
openstack-dev-requ...@lists.openstack.org?subject:unsubscribehttp://openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev