<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Tim,<BR> <BR>Here is a small change I wanted to try in runtime.py<BR>It may already exist in MaterializedViewTheory, but wasn't clear to me.<BR>Checking to see if this is something that:1. makes sense 2. already exists <BR>3. worth implementing? in that order.<BR> <BR>Let's take the example from private_public_network.classify<BR> <BR>error(vm) :- nova:virtual_machine(vm), nova:network(vm, network),<br> not neutron:public_network(network),<br> neutron:owner(network, netowner), nova:owner(vm, vmowner), not same_group(netowner, vmowner)<BR><br>same_group(user1, user2) :- cms:group(user1, group), cms:group(user2, group)<BR><br>nova:virtual_machine("vm1")<br>nova:virtual_machine("vm2")<br>nova:virtual_machine("vm3")<br>nova:network("vm1", "net_private")<br>nova:network("vm2", "net_public")<BR>neutron:public_network("net_public")<BR>nova:owner("vm1", "tim")<br>nova:owner("vm2", "pete")<br>nova:owner("vm3", "pierre")<br>neutron:owner("net_private", "martin")<br><BR> <BR>In this example, if as in Scenario 1:<BR> <BR>Cloud services at our disposal:<br>nova:virtual_machine(vm)<br>nova:network(vm, network)<br>nova:owner(vm, owner)<br>neutron:public_network(network)<br>neutron:owner(network, owner)<br>cms:group(user, group)<br><BR>are all python functions called through some nova/neutron api, <BR>then, we just execute them to get a true/false value in runtime.py<BR>They should be first checked to make sure they are python functions and<BR>not condition primitives using 'callable' and os.dir or some such combination.<BR> <BR>If not, and they are assertions made in the file, not directly related to OS<BR>state, then in Scenario 2<BR> <BR>nova:owner("vm1", "tim")<br>nova:owner("vm2", "pete")<br>nova:owner("vm3", "pierre")<br><BR>Are assertions made in the file. In a dynamic environment, <BR>a python function could query an OS client to actually find the current owner, <BR>since some other OS command could have been used to change the owner <BR>without an entry being made in this file, i.e., without explicitly informing Congres. <BR>This may not occur currently with vms, but may be implemented <BR>in a future release. Similar other examples are possible<BR><a href="https://ask.openstack.org/en/question/5582/how-to-change-ownership-between-tenants-of-volume/">https://ask.openstack.org/en/question/5582/how-to-change-ownership-between-tenants-of-volume/</a><BR><a href="https://blueprints.launchpad.net/cinder/+spec/volume-transfer">https://blueprints.launchpad.net/cinder/+spec/volume-transfer</a><BR> <BR> <BR>So, I was thinking that python_nova_owner("vm1"), is first checked as a python<BR>function which calls the appropriate OS client to check the current owner.<BR>As in nova:owner("vm1", python_nova_owner("vm1"))<BR> <BR>So, in runtime.py, in either scenario, condition primitives are first checked to <BR>see if it they are callable<BR>python functions (by using python 'callable' with os.dir). In which case, it is<BR>executed to get the name of the owner. All non-callable primitives are assumed<BR>assumed to be congress and/or datalog primitives, and unified through the<BR>Materializedviewtheory.<BR> <BR> <BR>Thanks,<BR> <BR><div>> Date: Thu, 13 Mar 2014 08:55:24 -0700<br>> From: thinrichs@vmware.com<br>> To: openstack-dev@lists.openstack.org<br>> Subject: Re: [openstack-dev] [Congress] Policy types<br>> <br>> Hi Prabhakar,<br>> <br>> I'm not sure the functionality is split between 'policy' and 'server' as cleanly as you describe.<br>> <br>> The 'policy' directory contains the Policy Engine. At its core, the policy engine has a generic Datalog implementation that could feasibly be used by other OS components. (I don't want to think about pulling it out into Oslo though. There are just too many other things going on and no demand yet.) But there are also Congress-specific things in that directory, e.g. the class Runtime in policy/runtime.py will be the one that we hook up external API calls to.<br>> <br>> The 'server' directory contains the code for the API web server that calls into the Runtime class.<br>> <br>> So if you're digging through code, I'd suggest focusing on the 'policy' directory and looking at compile.py (responsible for converting Datalog rules written as strings into an internal representation) and runtime.py (responsible for everything else). The docs I mentioned in the IRC should have a decent explanation of the functions in Runtime that the API web server will hook into. <br>> <br>> Be warned though that unless someone raises some serious objections to the proposal that started this thread, we'll be removing some of the more complicated functions from Runtime. The compile.py code won't change (much). All of the 3 new theories will be instances of MaterializedViewTheory. That's also the code that must change to add in the Python functions we talked about (more specifically see MaterializedViewTheory::propagate_rule(), which calls TopDownTheory::top_down_evaluation(), which is what will need modification).<br>> <br>> Tim<br>> <br>> <br>> <br>> <br>> ----- Original Message -----<br>> | From: "prabhakar Kudva" <nandavarpk@hotmail.com><br>> | To: "OpenStack Development Mailing List (not for usage questions)" <openstack-dev@lists.openstack.org><br>> | Sent: Wednesday, March 12, 2014 1:38:55 PM<br>> | Subject: Re: [openstack-dev] [Congress] Policy types<br>> | <br>> | <br>> | <br>> | <br>> | Hi Tim,<br>> | <br>> | Thanks for your comments.<br>> | Would be happy to contribute to the propsal and code.<br>> | <br>> | The existing code already reflects the thoughts below, and got me<br>> | in the line of ideas. Please orrect me if I am wrong as I am<br>> | learning with these discussions:<br>> | <br>> | One part (reflected by code in "policy" directory is the generic<br>> | "condition-> action engine" which could take logic primitives and<br>> | (in the future) python functions, evaluate the conditions and<br>> | execute the action. This portable core engine be used for any kind of<br>> | policy enforcement<br>> | (as by other OS projects), such as for data center monitoring and<br>> | repair,<br>> | service level enforcement, compliance policies, optimization (energy,<br>> | performance) etc... at any level of the stack. This core engine seems<br>> | possibly<br>> | a combination of logic reasoning/unification and python function<br>> | evaluation, and python code actions.<br>> | <br>> | Second part (reflected by code in "server") are the applications<br>> | for various purposes. These could be project specific, task specific.<br>> | We could add a diverse set of examples. The example I have worked<br>> | with seems closer to compliance (as in net owner, vm owner check),<br>> | and we will add more.<br>> | <br>> | Prabhakar<br>> | <br>> | <br>> | <br>> | Date: Wed, 12 Mar 2014 12:33:35 -0700<br>> | From: thinrichs@vmware.com<br>> | To: openstack-dev@lists.openstack.org<br>> | Subject: Re: [openstack-dev] [Congress] Policy types<br>> | <br>> | <br>> | <br>> | Hi Prabhakar,<br>> | <br>> | <br>> | Thanks for the feedback. I'd be interested to hear what other policy<br>> | types you have in mind.<br>> | <br>> | <br>> | To answer your questions...<br>> | <br>> | <br>> | We're planning on extending our policy language in such a way that<br>> | you can use Python functions as conditions ("<atom>" in the grammar)<br>> | in rules. That's on my todo-list but didn't mention it yesterday as<br>> | we were short on time. There will be some syntactic restrictions so<br>> | that we can properly execute those Python functions (i.e. we need to<br>> | always be able to compute the inputs to the function). I had thought<br>> | it was just an implementation detail I hadn't gotten around to (all<br>> | Datalog implementations I've seen have such things), but it sounds<br>> | like it's worth writing up a proposal and sending it around before<br>> | implementing. If that's a pressing concern for you, let me know and<br>> | I'll bump it up the stack (a little). If you'd like, feel free to<br>> | draft a proposal (or remind me to do it once in a while).<br>> | <br>> | <br>> | As for actions, I typically think of them as API calls to other OS<br>> | components like Nova. But they could just as easily be Python<br>> | functions. But I would want to avoid an action that changes<br>> | Congress's internal data structures directly (e.g. adding a new<br>> | policy statement). Such actions have caused trouble in the past for<br>> | policy languages (though for declarative programming languages like<br>> | Prolog they are less problematic). I don't think there's anyway we<br>> | can stop people from creating such actions, but I think we should<br>> | advocate against them.<br>> | <br>> | <br>> | Tim<br>> | <br>> | <br>> | <br>> | From: "prabhakar Kudva" <nandavarpk@hotmail.com><br>> | To: "OpenStack Development Mailing List (not for usage questions)"<br>> | <openstack-dev@lists.openstack.org><br>> | Sent: Wednesday, March 12, 2014 11:34:04 AM<br>> | Subject: Re: [openstack-dev] [Congress] Policy types<br>> | <br>> | <br>> | <br>> | Hi Tim, All,<br>> | <br>> | I was in the discussion yesterday (kudva), and would like to start<br>> | gradually<br>> | contributing to the code base.<br>> | <br>> | So, this discussion below is based on my limited exploration of<br>> | Congress<br>> | code, running it. I am trying some small pieces to implement to<br>> | familiarize.<br>> | Please view it as such. As I start adding code, I am sure, my<br>> | thoughts will<br>> | be more evolved.<br>> | <br>> | I agree with the three types you outline. I also agree that these<br>> | will grow.<br>> | We are already thinking of expanding congress for various other types<br>> | of<br>> | policies. But those would be a manageable start.<br>> | <br>> | Regarding the comment below. I was wondering if all conditions, and<br>> | actions<br>> | could be both:<br>> | 1. python functions (for conditions they eval<br>> | 2. policy primitives.<br>> | <br>> | The advantage of 1, is that it is just executed and a True or False<br>> | returned<br>> | by Python for conditions. For actions, python functions are executed<br>> | to respond to conditions.<br>> | This controls the growth of policies and adding more primitives, and<br>> | makes it flexible (say<br>> | to use alarms, monitors, os clients, nova actions etc).<br>> | <br>> | The advantage of 2, is the ability to use unification (as in<br>> | unify.py) and do<br>> | some logic reduction. This gives us the full strength of extensive<br>> | and mature<br>> | logic reasoning and reduction methods.<br>> | <br>> | One possibility is that it checks which one the two it is and does<br>> | the appropriate<br>> | evaluation for condition and action.<br>> | <br>> | <br>> | <br>> | <br>> | >There are drawbacks to this proposal as well.<br>> | >- We will have 3 separate policies that are conceptually very<br>> | >similar. As the policies grow larger, it will become >increasingly<br>> | >difficult to keep the policies synchronized. This problem can be<br>> | >mitigated to some extent by having >all 3 share a library of policy<br>> | >statements that they all apply in different ways (and such a<br>> | >library mechanism is >already implemented).<br>> | >- As cloud services change their behavior, policies may need to be<br>> | >re-written. For example, right now Nova does >not consult Congress<br>> | >before creating a VM; thus, to enforce policy surrounding VMs, the<br>> | >best we could do is >write a Condition-Action policy that adjusts<br>> | >VM configuration when it learns about new VMs being created. If we<br>> | >>later make Nova consult with Congress before creating a VM, we<br>> | >need to write an Access-control policy that puts >the proper<br>> | >controls in place.<br>> | Thanks,<br>> | <br>> | Prabhakar Kudva<br>> | <br>> | <br>> | <br>> | <br>> | <br>> | <br>> | <br>> | <br>> | Date: Wed, 12 Mar 2014 10:05:23 -0700<br>> | From: thinrichs@vmware.com<br>> | To: openstack-dev@lists.openstack.org<br>> | Subject: [openstack-dev] [Congress] Policy types<br>> | <br>> | <br>> | <br>> | <br>> | Hi all,<br>> | <br>> | <br>> | We started a discussion on IRC yesterday that I'd like to continue.<br>> | The main question is what kind of policy does a Congress user<br>> | actually write? I can see three options. The first two focus on<br>> | actions (API calls that make changes to the state of the cloud) and<br>> | the last focuses on just the cloud state. (By "state of the cloud" I<br>> | mean all the information Congress can see about all the cloud<br>> | services it is managing, e.g. all the information we can get through<br>> | API calls to Nova, Neutron, Cinder, Heat, ...).<br>> | <br>> | <br>> | 1) Access Control (e.g. Linux, XACML, AD): which *actions* can be<br>> | performed by other cloud services (for each state of the cloud)<br>> | 2) Condition Action: which *actions* Congress should execute (for<br>> | each state of the cloud)<br>> | 3) Classification (currently supported in Congress): which *states*<br>> | violate real-world policy. [For those of you who have read<br>> | docs/white-papers/etc. I'm using "Classification" in this note to<br>> | mean the combination of the current "Classification" and "Action<br>> | Description" policies.]<br>> | <br>> | <br>> | The important observation is that each of these policies could<br>> | contain different information from each of the others.<br>> | <br>> | <br>> | <br>> | - Access Control vs Condition Action. The Access Control policy tells<br>> | *other cloud services* which actions they are *allowed* to execute.<br>> | The Condition Action policy tells *Congress* which actions it *must*<br>> | execute. These policies differ because they constrain different sets<br>> | of cloud services.<br>> | <br>> | <br>> | - Access Control vs. Classification. The Access Control policy might<br>> | permit some users to violate the Classification policy in some<br>> | situations (e.g. to fix violation A, we might need to cause<br>> | violation B before eliminating both). These policies differ because<br>> | a violation in one policy might be be a violation in the other.<br>> | <br>> | <br>> | - Classification vs. Condition Action. The Classification policy<br>> | might imply which actions *could* eliminate a given violation, but<br>> | the Condition Action policy would dictate which of those actions<br>> | *should* be executed (e.g. the Classification policy might tell us<br>> | that disconnecting a network and deleting a VM would both eliminate<br>> | a particular violation, but the Condition Action policy would tell<br>> | us which to choose). And the Condition Action policy need not<br>> | eliminate all the violations present in the Classification policy.<br>> | Again these policies differ because a violation in one policy might<br>> | not be a violation in the other.<br>> | <br>> | <br>> | <br>> | I'm proposing that for the first release of Congress we support all 3<br>> | of these policies. When a user inserts/deletes a policy statement,<br>> | she chooses which policy it belongs to. All would be written in<br>> | basically the same syntax but would be used in 3 different<br>> | scenarios:<br>> | <br>> | <br>> | - Prevention: If a component wants to consult Congress before taking<br>> | action to see if that action is allowed, Congress checks the Access<br>> | Control policy.<br>> | <br>> | <br>> | - Reaction: When Congress learns of a change in the cloud's state, it<br>> | checks the Condition Action policy to see which actions should be<br>> | executed (if any).<br>> | <br>> | <br>> | - Monitoring: If a user wants to simply check if the cloud's state is<br>> | in compliance and monitor compliance over time, she writes and<br>> | queries the Classification policy.<br>> | <br>> | <br>> | There are several benefits to this proposal.<br>> | - It allows users to choose any of the policy types, if they only<br>> | want one of them. From our discussions with potential users, most<br>> | seem to want one of these 3 policy types (and are uninterested in<br>> | the others).<br>> | - It makes the introduction to Congress relatively simple. We<br>> | describe 3 different uses of policy (Prevention, Reaction,<br>> | Monitoring) and then explain which policy to use in which case.<br>> | <br>> | - This allows us to focus on implementing a single policy-engine<br>> | technology (a Datalog policy language and evaluation algorithms),<br>> | which gives us the opportunity to make it solid.<br>> | <br>> | <br>> | There are drawbacks to this proposal as well.<br>> | - We will have 3 separate policies that are conceptually very<br>> | similar. As the policies grow larger, it will become increasingly<br>> | difficult to keep the policies synchronized. This problem can be<br>> | mitigated to some extent by having all 3 share a library of policy<br>> | statements that they all apply in different ways (and such a library<br>> | mechanism is already implemented).<br>> | - As cloud services change their behavior, policies may need to be<br>> | re-written. For example, right now Nova does not consult Congress<br>> | before creating a VM; thus, to enforce policy surrounding VMs, the<br>> | best we could do is write a Condition-Action policy that adjusts VM<br>> | configuration when it learns about new VMs being created. If we<br>> | later make Nova consult with Congress before creating a VM, we need<br>> | to write an Access-control policy that puts the proper controls in<br>> | place.<br>> | <br>> | <br>> | These drawbacks were the original motivation for supporting only the<br>> | Classification policy and attempting to derive the Access Control<br>> | and Condition Action policies from it. But given that we can't<br>> | always derive the proper Access Control and Condition Action<br>> | policies from the Classification policy, we will eventually need<br>> | support for all 3. In addition, the technical complexity of<br>> | supporting all 3 is much lower than supporting just the<br>> | Classification policy and deriving the others.<br>> | <br>> | <br>> | I'll stop there for now.<br>> | <br>> | <br>> | Comments, thoughts, questions?<br>> | Tim<br>> | <br>> | <br>> | _______________________________________________ OpenStack-dev mailing<br>> | list OpenStack-dev@lists.openstack.org<br>> | http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br>> | _______________________________________________<br>> | OpenStack-dev mailing list<br>> | OpenStack-dev@lists.openstack.org<br>> | https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=%2FZ35AkRhp2kCW4Q3MPeE%2BxY2bqaf%2FKm29ZfiqAKXxeo%3D%0A&m=4QiYdqIhBIaa%2FY1uu8c2Wq%2F92NWfXkaUvJLsncl4ccI%3D%0A&s=a18a843e031ec87277e04caa8396b5cf71bc7a2e5252247084abacf0b9e51409<br>> | <br>> | <br>> | <br>> | _______________________________________________ OpenStack-dev mailing<br>> | list OpenStack-dev@lists.openstack.org<br>> | http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br>> | _______________________________________________<br>> | OpenStack-dev mailing list<br>> | OpenStack-dev@lists.openstack.org<br>> | https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=%2FZ35AkRhp2kCW4Q3MPeE%2BxY2bqaf%2FKm29ZfiqAKXxeo%3D%0A&m=SMheq3u5q7x9wYFjxnNx6C%2F9lZgxydUP452rygu28MY%3D%0A&s=5c1cf9f3a5adc86ce59d2bf582891e0da033394f43a6ffa72127843c8cf78f80<br>> | <br>> <br>> _______________________________________________<br>> OpenStack-dev mailing list<br>> OpenStack-dev@lists.openstack.org<br>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br></div> </div></body>
</html>