Running a policy from another policy?
Hi.
I want to run policies depending on some custom conditions. They only way I can imagine to implements this it's creating a custom policy that check the conditions and fire the right policy. So, is it possible to run policies using the policy API? Any other possible approach?
Regards,
-unai
I want to run policies depending on some custom conditions. They only way I can imagine to implements this it's creating a custom policy that check the conditions and fire the right policy. So, is it possible to run policies using the policy API? Any other possible approach?
Regards,
-unai
3 answers
A policy gets to run on a server thread, as a response to an asset event (e.g., enters a state, update ...). The policy gets a context (the asset, policy configuration on that state ....).
What the policy does, and what code it returns when it ends, is up to that policy. Policy can update the (context) asset, other assets... delegate work to other systems (e.g., build / automation, opening a change request ...), or read a rule file (say an XML content from another asset) to determine what to do. The last one imply that you have one generic policy that do different thing based on the environment it is executing, and the rules associated with that environment.
Not sure for the exact reason you want a policy to "fire the right policy" ...
Can you provide an example, specifically, when is the "main" policy activated, what what conditions it will drive what action
What the policy does, and what code it returns when it ends, is up to that policy. Policy can update the (context) asset, other assets... delegate work to other systems (e.g., build / automation, opening a change request ...), or read a rule file (say an XML content from another asset) to determine what to do. The last one imply that you have one generic policy that do different thing based on the environment it is executing, and the rules associated with that environment.
Not sure for the exact reason you want a policy to "fire the right policy" ...
Can you provide an example, specifically, when is the "main" policy activated, what what conditions it will drive what action
Simple example: imagine I want to send an email to asset owner depending on some custom conditions. I could associate default 'send email' policy with the state but with no event. Then I could run this policy from another policy that checks custom conditions, passing the 'policy context' to default 'send email' policy.
Obviously, I can create some custom code that implements the 'send email' behaviour, but in that case I can not reuse default policy. This applies to the rest of default policies.
Also, RAM could track what policies were run on that asset/state and show them in web UI. That applies also to custom policies. If I have rules A, B and C, and they are executed as policies from Controler policy, RAM web UI would show policies A, B, C and Controler were executed on that asset. But if they are implemented as rules inside my custom code, only Controler would be showed.
Obviously, I can create some custom code that implements the 'send email' behaviour, but in that case I can not reuse default policy. This applies to the rest of default policies.
Also, RAM could track what policies were run on that asset/state and show them in web UI. That applies also to custom policies. If I have rules A, B and C, and they are executed as policies from Controler policy, RAM web UI would show policies A, B, C and Controler were executed on that asset. But if they are implemented as rules inside my custom code, only Controler would be showed.