Merge "Update api docs to reflect the most recent changes to policytypes"
[policy/parent.git] / docs / xacml / xacml.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2
3 .. _xacml-label:
4
5 Policy XACML PDP Engine
6 #######################
7
8 .. toctree::
9    :maxdepth: 2
10
11 The ONAP XACML Policy PDP Engine uses an `open source implementation <https://github.com/att/XACML>`__ of the `OASIS XACML 3.0 Standard <https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xacml>`__ to support fine-grained policy decisions in the ONAP. The XACML 3.0 Standard is a language for both policies and request/response for access control decisions. The ONAP XACML PDP translates TOSCA Compliant Policies into the XACML policy language, loads the policies into the XACML engine and exposes a Decision API which uses the XACML request/response language to render decisions.
12
13 ONAP Supported Policy Types
14 ***************************
15
16 In ONAP the following Policy Types are supported. Each Policy Type is implemented as an application that extends the **XacmlApplicationServiceProvider**. For details on each implementation, please refer to the `applications submodule of the onap/xacml-pdp project <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=tree;f=applications;h=047878fe14851d8a51998e065b8aca583ed8c994;hb=refs/heads/elalto>`__.
17
18 By cloning the policy/xacml-pdp repository, one can run the JUnit tests to get a better understanding on how applications are built using translators and the XACML Policies that are generated for each Policy Type. Each application supports one or more Policy Types and an associated "action" used by the Decision API when making these calls.
19
20 Monitoring Policy Types
21 =======================
22 These Policy Types are used by Control Loop DCAE microservice components to support monitoring of VNF's during Control Loops. The DCAE Platform makes a call to Decision API to request the contents of these policies. The implementation involves creating an overarching XACML Policy that contains the TOSCA policy as a payload that is returned to the DCAE Platform.
23
24 .. csv-table::
25    :header: "Policy Type", "Action", "Description"
26
27    "onap.policies.monitoring.cdap.tca.hi.lo.app", "configure", "TCA DCAE microservice component"
28    "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server", "configure", "REST Collector"
29
30 The translator used to translate these TOSCA Policy Types is the `StdCombinedPolicyResultsTranslator <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=blob;f=applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java;h=2d7386d99f97ccee828b665a46b46531495cdfcd;hb=refs/heads/elalto>`__.
31
32 This is an example Decision API payload made to retrieve a decision for a Monitoring Policy Type.
33
34 .. literalinclude:: decision.monitoring.json
35   :language: JSON
36
37 Guard Policy Types
38 ==================
39 These Policy Types are used by Control Loop Drools Engine to support guarding of Control Loops during runtime control loop execution. NOTE: For El Alto, these policy types are not TOSCA compliant but rather a simple variation of the Casablanca legacy guard policy.
40
41 .. csv-table::
42    :header: "Policy Type", "Action", "Description"
43
44    "onap.policies.controlloop.guard.FrequencyLimiter", "guard", "Limits frequency of actions over a specified time period"
45    "onap.policies.controlloop.guard.Blacklist", "guard", "Blacklists a regexp of VNF IDs"
46    "onap.policies.controlloop.guard.MinMax", "guard", "For scaling, enforces a min/max number of VNFS"
47
48 The translator used to translate these legacy Policy Types is the `LegacyGuardTranslator <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=blob;f=applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java;h=2917aab26dfbcf805dd00fead66ef68439561a11;hb=refs/heads/elalto>`__ which implements a more fine grained approach to translating the properties into a XACML policy.
49
50 This is an example Decision API payload made to retrieve a decision for a Guard Policy Type.
51
52 .. literalinclude:: decision.guard.json
53   :language: JSON
54
55
56 Control Loop Coordination Policy Types
57 ======================================
58 These Policy Types are similar to the guard Policy Types and are called by the Control Loop Drools PDP Engine to support guarding of Control Loops during runtime control loop execution. NOTE: For Dublin, these Policy Types are not tested by the Integration team and are available as prototypes.
59
60 .. csv-table::
61    :header: "Policy Type", "Action", "Description"
62
63    "onap.policies.controlloop.guard.coordination.FirstBlocksSecond", "guard", "Gives priority to one control loop vs another"
64
65 The translator used to translate the coordination Policy Types is the `CoordinationGuardTranslator <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=blob;f=applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java;h=41c1428e3da4cc5b6c1bb091d0c16a6618a036ae;hb=refs/heads/elalto>`__ which uses a XACML Policy Template in its implementation. For example, when a new policy is loaded the translator copies the template to a new policy and replaces the CONTROL_LOOP_ONE and CONTROL_LOOP_TWO values with the specified control loops. See the `XAMCL Coordination Template for more details <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=blob;f=applications/guard/src/main/resources/coordination/function/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.xml;h=bea05f264be5e422eb2da448d40057f736b7555c;hb=refs/heads/elalto>`__.
66
67 The same Decision API payload example for guard applies to this Policy Type.
68
69 Optimization Policy Types
70 =========================
71 These Policy Types are designed to be used by the OOF Project support placement in ONAP. The OOF Platform makes a call to the Decision API to request these Policies based on the values specified in the onap.policies.Optimization properties that have a metadata property called "matchable" and its value is set to "true". NOTE: For El Alto, this is dark code and OOF has not yet upgraded to the new Decision API to support this. Please refer to the OOF Project for more details on how it currently uses the Legacy API and policy models in their platform.
72
73 .. csv-table::
74    :header: "Policy Type", "Action"
75
76    "onap.policies.Optimization", "optimize"
77    "onap.policies.optimization.AffinityPolicy", "optimize"
78    "onap.policies.optimization.DistancePolicy", "optimize"
79    "onap.policies.optimization.HpaPolicy", "optimize"
80    "onap.policies.optimization.OptimizationPolicy", "optimize"
81    "onap.policies.optimization.PciPolicy", "optimize"
82    "onap.policies.optimization.QueryPolicy", "optimize"
83    "onap.policies.optimization.SubscriberPolicy", "optimize"
84    "onap.policies.optimization.Vim_fit", "optimize"
85    "onap.policies.optimization.VnfPolicy", "optimize"
86
87 The translator used to translate the optimization Policy Types is the `StdMatchableTranslator <https://gerrit.onap.org/r/gitweb?p=policy/xacml-pdp.git;a=blob;f=applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java;h=dd44af7aa4ab2ef70b216f8a3a6a02c6f1fddf56;hb=refs/heads/elalto>`__.
88
89 This is an example Decision API payload made to retrieve a decision for an Optimization Policy Type.
90
91 .. literalinclude:: decision.affinity.json
92   :language: JSON
93
94 Supporting Custom Policy Types
95 ******************************
96 In order to support your own custom Policy Type that the XACML PDP Engine can support, one needs to build a Java service application that extends the **XacmlApplicationServiceProvider** interface and implement a **ToscaTranslator** application. Your application should register itself as a Java service application and expose it in the classpath used to be loaded into the ONAP XACML PDP Engine. Ensure you define and create the TOSCA Policy Type according to these :ref:`Policy Design and Development <design-label>`. You should be able to load your custom Policy Type using the :ref:`Policy Lifecycle API <api-label>`. Once successful, you should be able to start creating policies from your custom Policy Type.
97
98 See each of the ONAP Policy Type application implementations for for ONAP re-use the **StdXacmlApplicationServiceProvider** class. They give simple examples on how to use various implementations of **ToscaTranslator** applications.
99
100 The following tutorial can be helpful to get started: :ref:`xacmltutorial-label`
101
102 Once your application is developed and the ONAP XACML PDP Engine can find your application via setting the classpath appropriately, then use the :ref:`PAP REST API <pap-label>` to ensure the ONAP XACML PDP is registering your custom Policy Type with the PAP. Once successful, then you should be able to start deploying the created policies to the XACML PDP Engine.
103
104 .. _decision-api-label:
105
106 Decision API
107 ************
108 The Decision API is used by ONAP components that enforce policies and need a decision on which policy to enforce for a specific situation. The Decision API mimics closely the XACML request standard in that it supports a subject, action and resource.
109
110 .. csv-table::
111    :header: "Field", "Required", "XACML equivalent", "Description"
112
113    "ONAPName", "True", "subject", "The name of the ONAP project making the call"
114    "ONAPComponent", "True", "subject", "The name of the ONAP sub component making the call"
115    "ONAPInstance", "False", "subject", "An optional instance ID for that sub component"
116    "action", "True", "action", "The action being performed"
117    "resource", "True", "resource", "An object specific to the action that contains properties describing the resource"
118
119 It is worth noting that we use basic authorization for API access with username and password set to *healthcheck* and *zb!XztG34* respectively.
120 Also, the new APIs support both *http* and *https*.
121
122 For every API call, client is encouraged to insert an uuid-type requestID as parameter. It is helpful for tracking each http transaction
123 and facilitates debugging. Mostly importantly, it complies with Logging requirements v1.2. If client does not provider the requestID in API call,
124 one will be randomly generated and attached to response header *x-onap-requestid*.
125
126 In accordance with `ONAP API Common Versioning Strategy Guidelines <https://wiki.onap.org/display/DW/ONAP+API+Common+Versioning+Strategy+%28CVS%29+Guidelines>`_,
127 in the response of each API call, several custom headers are added::
128
129     x-latestversion: 1.0.0
130     x-minorversion: 0
131     x-patchversion: 0
132     x-onap-requestid: e1763e61-9eef-4911-b952-1be1edd9812b
133
134 x-latestversion is used only to communicate an API's latest version.
135
136 x-minorversion is used to request or communicate a MINOR version back from the client to the server, and from the server back to the client.
137
138 x-patchversion is used only to communicate a PATCH version in a response for troubleshooting purposes only, and will not be provided by the client on request.
139
140 x-onap-requestid is used to track REST transactions for logging purpose, as described above.
141
142 .. swaggerv2doc:: swagger.json
143
144
145 End of Document