コード例 #1
0
 def run_all_policies(self, mode=None):
     """
     Runs all policies in the specified mode
     """
     Context.set_mode(mode)
     for policy in self._policies:     
         self.run_policy(policy=policy)
コード例 #2
0
    def validate_role(self, role):
        """
        Validates inputs for one role
        """

        def validate(resource):
            return resource.validate
        
        # resources and handlers must be processed seperately
        # the validate method will raise exceptions when problems are found
        original_mode = Context.mode()
        Context.set_mode(VALIDATE)
        role.walk_children(items=role.get_children('resources'), which='resources', fn=validate, tags=self._tags)
        role.walk_children(items=role.get_children('handlers'), which='handlers', fn=validate)
        if original_mode:
            Context.set_mode(original_mode)