PDP
PDP
PDP ( PolicyDecisionPoint ) is the back-end for the PolicySystem. It discovers the policies, finds the best match, evaluates them, merges their results taking the most penalizing one, computes the set of actions to be triggered and returns all the information to the PEP which will enforce the actions.
- class DIRAC.ResourceStatusSystem.PolicySystem.PDP.PDP(Policy Decision Point)
Bases:
object
- __init__(clients=None)
Constructor.
Examples
>>> pdp = PDP( None ) >>> pdp1 = PDP( {} ) >>> pdp2 = PDP( { 'Client1' : Client1Object } )
- Parameters:
- clients - [ None, dict ]
dictionary with Clients to be used in the Commands. If None, the Commands will create their own clients.
- setup(decisionParams=None)
method that sanitizes the decisionParams and ensures that at least it has the keys in standardParamsDict. This will be relevant while doing the matching with the RSS Policies configuration in the CS. There is one key-value pair, active which is added on this method. This allows policies to be de-activated from the CS, changing their active matchParam to something else than Active.
Examples
>>> pdp.setup( None ) >>> self.decisionParams { 'element' : None, 'name' : None, ... } >>> pdp.setup( { 'element' : 'AnElement' } ) >>> self.decisionParams { 'element' : 'AnElement', 'name' : None, ... } >>> pdp.setup( { 'NonStandardKey' : 'Something' } ) >>> self.decisionParams { 'NonStandardKey' : 'Something', 'element' : None,... }
- Parameters:
- decisionParams - [ None, dict ]
dictionary with the parameters to be matched with the RSS Policies configuration in the CS.
- takeDecision()
main PDP method which does all the work. If firstly finds all the policies defined in the CS that match <self.decisionParams> and runs them. Once it has all the singlePolicyResults, it combines them. Next step is action discovery: using a similar approach to the one used to discover the policies, but also taking into account the single policy results and their combined result, finds the actions to be triggered and returns.
Examples
>>> list(pdp.takeDecision()['Value']) ['singlePolicyResults', 'policyCombinedResult', 'decisionParams'] >>> pdp.takeDecision()['Value']['singlePolicyResults'] [ { 'Status' : 'Active', 'Reason' : 'blah', 'Policy' : { 'name' : 'AlwaysActiveForResource', 'type' : 'AlwaysActive', 'module' : 'AlwaysActivePolicy', 'description' : 'This is the AlwaysActive policy' 'command' : None, 'args' : {} } }, ... ] >>> pdp.takeDecision()['Value']['policyCombinedResult'] { 'Status' : 'Active', 'Reason' : 'blah ###', 'PolicyAction' : [ ( 'policyActionName1', 'policyActionType1' ), ... ] }
- Returns:
S_OK( { ‘singlePolicyResults’ : list, ‘policyCombinedResult’ : dict, ‘decisionParams’ : dict } ) / S_ERROR