1 from sfatables.runtime import SFATablesRules
3 def fetch_context(slice_hrn, user_hrn, contexts):
5 Returns the request context required by sfatables. At some point, this
6 mechanism should be changed to refer to "contexts", which is the
7 information that sfatables is requesting. But for now, we just return
8 the basic information needed in a dict.
10 base_context = {'sfa':{'user':{'hrn':user_hrn}, 'slice':{'hrn':slice_hrn}}}
13 def run_sfatables(chain, hrn, origin_hrn, rspec, context_callback = None ):
15 Run the rspec through sfatables
16 @param chain Name of rule chain
17 @param hrn Object's hrn
18 @param origin_hrn Original caller's hrn
19 @param rspec Incoming rspec
20 @param context_callback Callback used to generate the request context
24 if not context_callback:
25 context_callback = fetch_context
28 rules = SFATablesRules(chain)
29 if rules.sorted_rule_list:
30 contexts = rules.contexts
31 request_context = context_callback(hrn, origin_hrn, contexts)
32 rules.set_context(request_context)
33 newrspec = rules.apply(rspec)