Beispiel #1
0
 def set_policy(self, name, policyStr):
     if name is None:
         name = DEFAULT_POLICY_NAME
     with self.policy_sem:
         oldStr = self.policy_strings.get(name)
         if policyStr is None:
             try:
                 del self.policy_strings[name]
                 self.logger.info("Deleted policy '%s'", name)
             except KeyError:
                 pass
         else:
             self.policy_strings[name] = policyStr
         try:
             self.code = get_code(Evaluator(), self._cat_policies())
         except PolicyError, e:
             self.logger.warn("Unable to load policy: %s" % e)
             if oldStr is None:
                 del self.policy_strings[name]
             else:
                 self.policy_strings[name] = oldStr
             return False
         if policyStr:
             self.logger.info("Loaded policy '%s'", name)
         return True
Beispiel #2
0
 def set_policy(self, name, policyStr):
     if name is None:
         name = DEFAULT_POLICY_NAME
     with self.policy_sem:
         oldStr = self.policy_strings.get(name)
         if policyStr is None:
             try:
                 del self.policy_strings[name]
                 self.logger.info("Deleted policy '%s'", name)
             except KeyError:
                 pass
         else:
             self.policy_strings[name] = policyStr
         try:
             self.code = get_code(Evaluator(), self._cat_policies())
         except PolicyError, e:
             self.logger.warn("Unable to load policy: %s" % e)
             if oldStr is None:
                 del self.policy_strings[name]
             else:
                 self.policy_strings[name] = oldStr
             return False
         if policyStr:
             self.logger.info("Loaded policy '%s'", name)
         return True
Beispiel #3
0
 def __init__(self, policy_string):
     self.logger = logging.getLogger('mom.Policy')
     self.policy_string = policy_string
     self.evaluator = Evaluator()
     self.code = get_code(self.evaluator, self.policy_string)
Beispiel #4
0
 def __init__(self, policy_string):
     self.policy_string = policy_string
     self.evaluator = Evaluator()
     self.code = get_code(self.evaluator, self.policy_string)