X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2FsfatablesRuntime.py;h=2266b3117fca461df626669ea82e3e390dca6e2c;hb=HEAD;hp=d1a4e6cc80b5233fce8a409f1d29c279ea1f8e4c;hpb=3d51e29695f79b143974f5cf7b2e104d89626ba4;p=sfa.git diff --git a/sfa/util/sfatablesRuntime.py b/sfa/util/sfatablesRuntime.py index d1a4e6cc..2266b311 100644 --- a/sfa/util/sfatablesRuntime.py +++ b/sfa/util/sfatablesRuntime.py @@ -1,6 +1,6 @@ # sfa should not depend on sfatables # if the sfatables.runtime import fails, just define run_sfatables as identity -import sys + try: from sfatables.runtime import SFATablesRules @@ -11,10 +11,11 @@ try: information that sfatables is requesting. But for now, we just return the basic information needed in a dict. """ - base_context = {'sfa':{'user':{'hrn':user_hrn}, 'slice':{'hrn':slice_hrn}}} + base_context = { + 'sfa': {'user': {'hrn': user_hrn}, 'slice': {'hrn': slice_hrn}}} return base_context - def run_sfatables(chain, hrn, origin_hrn, rspec, context_callback = None ): + def run_sfatables(chain, hrn, origin_hrn, rspec, context_callback=None): """ Run the rspec through sfatables @param chain Name of rule chain @@ -22,15 +23,14 @@ try: @param origin_hrn Original caller's hrn @param rspec Incoming rspec @param context_callback Callback used to generate the request context - + @return rspec """ if not context_callback: context_callback = fetch_context - + chain = chain.upper() rules = SFATablesRules(chain) - print>>sys.stderr, " \r\n \r\n \t\t \t sfaTablesRuntime.py run_sfatables context_callback %s chain %s rules %s " %(context_callback,chain, rules ) if rules.sorted_rule_list: contexts = rules.contexts request_context = context_callback(hrn, origin_hrn, contexts) @@ -41,8 +41,10 @@ try: return newrspec except: - + from sfa.util.sfalogging import logger - def run_sfatables (_,__,___, rspec, ____=None): - logger.warning("Cannot import sfatables.runtime, please install package sfa-sfatables") + + def run_sfatables(_, __, ___, rspec, ____=None): + logger.warning( + "Cannot import sfatables.runtime, please install package sfa-sfatables") return rspec