Bases: congress.policy_engines.agnostic.Runtime, congress.dse2.data_service.DataService
Event handler for action execution.
Parameters: | service_name – openstack service to perform the action on, |
---|
e.g. ‘nova’, ‘neutron’ :param action: action to perform on service, e.g. an API call :param action_args: positional-args and named-args in format:
{‘positional’: [‘p_arg1’, ‘p_arg2’], ‘named’: {‘name1’: ‘n_arg1’, ‘name2’: ‘n_arg2’}}.
Initialize table subscription.
Once policies have all been loaded, this function subscribes to all the necessary tables. See UPDATE_TABLE_SUBSCRIPTIONS as well.
handler for policy table subscription
when a previously non-subscribed table gains a subscriber, register a trigger for the tables and publish table results when there is updates.
Remove triggers when tables have no subscribers.
Called before push.
Takes as input the DATA that the receiver needs and returns the payload for the message. If this is a regular publication message, make the payload just the delta; otherwise, make the payload the entire table.
Callback for policy table triggers.
Event handler for when a dataservice publishes data.
That data can either be the full table (as a list of tuples) or a delta (a list of Events).
Handler for when dataservice publishes full table.
Handler for when dataservice publishes a delta.
Update table subscription.
Change the subscriptions from OLDTABLES to NEWTABLES, ensuring to load all the appropriate services.
Bases: object
RPC endpoints exposed by DseRuntime.
Bases: object
Bases: congress.policy_engines.agnostic.Runtime
Event handler for making access_control request.
ACTION is an atom describing a proposed action instance. SUPPORT is any data that should be assumed true when posing the query. Returns True iff access is granted.
Event handler for execute:
Execute a sequence of ground actions in the real world.
Executes the list of ACTION instances one at a time.
For now, our execution is just logging.
Event handler for explanations.
Given a ground query and a collection of tablenames that we want the explanation in terms of, return proof(s) that the query is true. If FIND_ALL is True, returns list; otherwise, returns single proof.
Event handler for remediation.
Find a collection of action invocations
That if executed result in FORMULA becoming false.
Bases: object
Runtime for the Congress policy language.
Only have one instantiation in practice, but using a class is natural and useful for testing.
Add policy obj to runtime
Return number of columns for TABLE in THEORY.
TABLE can include the policy name. <policy>:<table> THEORY is the name of the theory we are asking. MODAL is the value of the modal, if any.
Checks if policy exists or not.
Parameters: | policy_name – policy name |
---|---|
Returns: | True, if policy exists |
Raises: | PolicyRuntimeException, if policy doesn’t exist. |
Construct policy obj
Event handler for querying content().
Create a new policy and add it to the runtime.
ABBR is a shortened version of NAME that appears in traces. KIND is the name of the datastructure used to represent a policy.
Event handler for arbitrary deletion (rules and facts).
Deletes policy with name NAME or throws KeyError or DanglingRefs.
Return a subset of rules in @theory.
@required_tables is the set of tablenames that a rule must depend on. @prohibited_tables is the set of tablenames that a rule must NOT depend on. @output_tables is the set of tablenames that all rules must support.
Return a list of the names of action tables.
Resolve NAME to the name of a proper policy (even if it is None).
Raises PolicyException there is no such policy.
Return (Runtime’s tracer, dict of tracers for each theory).
Useful so we can temporarily change tracing.
Initializes datasource by creating policy and setting schema.
Event handler for (re)initializing a collection of tables
@facts must be an iterable containing compile.Fact objects.
Event handler for arbitrary insertion (rules and facts).
Return data for all rules in policy_name.
Insert and persists rule into policy_name.
Load policies from database.
Load all rules from the database.
Event handler for querying policy.
Returns list of policy names.
Return policy by given name. Raises KeyError if does not exist.
Return type of policy NAME. Throws KeyError if does not exist.
Apply the list of updates SEQUENCE.
Apply the list of updates SEQUENCE, where actions are described in ACTION_THEORY. Return an update sequence that will undo the projection.
SEQUENCE can include atom insert/deletes, rule insert/deletes, and action invocations. Projecting an action only simulates that action’s invocation using the action’s description; the results are therefore only an approximation of executing actions directly. Elements of SEQUENCE are just formulas applied to the given THEORY. They are NOT Event()s.
SEQUENCE is really a program in a mini-programming language–enabling results of one action to be passed to another. Hence, even ignoring actions, this functionality cannot be achieved by simply inserting/deleting.
Project atom/delta rule insertion/deletion.
Takes an atom/rule DELTA with update head table (i.e. ending in + or -) and inserts/deletes, respectively, that atom/rule into THEORY after stripping the +/-. Returns None if DELTA had no effect on the current state.
Register CALLBACK to run when table TABLENAME changes.
Renames policy OLDNAME to NEWNAME or raises KeyError.
If p+(args) and p-(args) are present, removes the p-(args).
Event handler for arbitrary queries.
Returns the set of all instantiated QUERY that are true.
Set the schema for module NAME to be SCHEMA.
Event handler for simulation.
:param query is a string/object to query after :param theory is the policy to query :param sequence is a string/iter of updates to state/policy or actions :param action_theory is the policy that contains action descriptions :param delta indicates whether to return changes to query caused by
sequence
Returns a list of instances of query. If query/sequence are strings the query instance list is a single string (unless as_list is True in which case the query instance list is a list of strings). If query/sequence are objects then the query instance list is a list of objects.
The computation of a query given an action sequence. That sequence can include updates to atoms, updates to rules, and action invocations. Returns a collection of Literals (as a string if the query and sequence are strings or as a Python collection otherwise). If delta is True, the return is a collection of Literals where each tablename ends with either + or - to indicate whether that fact was added or deleted. Example atom update: q+(1) or q-(1) Example rule update: p+(x) :- q(x) or p-(x) :- q(x) Example action invocation:
create_network(17), options:value(17, “name”, “net1”) :- true
Return list of queries yielding contents of TABLENAME in POLICY.
Return tablenames occurring in some theory.
Unregister CALLBACK for table TABLENAME.
Event handler for applying an arbitrary sequence of insert/deletes.
If TARGET is supplied, it overrides the targets in SEQUENCE.
Bases: object
A chunk of code that should be run when a table’s contents changes.
Bases: object
A collection of triggers and algorithms to analyze that collection.
Register CALLBACK to run when TABLENAME changes.
Return the set of triggers that are relevant to the EVENTS.
Each EVENT may either be a compile.Event or a tablename.
Return dictionary from tables to triggers.
Unregister trigger ID.
Inform registry of changes to the dependency graph.
Changes are accounted for in self.dependency_graph, but by giving the list of changes we can avoid recomputing all dependencies from scratch.