blob: d543e46194ce1a94f5632cd8f47520ac12b095dd [file] [log] [blame]
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -04001.. This work is licensed under a
2.. Creative Commons Attribution 4.0 International License.
3.. http://creativecommons.org/licenses/by/4.0
4
5.. _design-label:
6
7Policy Design and Development
liamfallon4d1d9832019-05-30 20:53:05 +00008#############################
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -04009
10.. contents::
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040011 :depth: 4
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040012
liamfallon4d1d9832019-05-30 20:53:05 +000013This document describes the design principles that should be used to write, deploy, and run policies of various types
14using the Policy Framework. It explains the APIs that are available for Policy Framework users. It provides copious
15examples to illustrate policy design and API usage.
liamfallonc9e27902019-05-28 13:27:04 +000016
liamfallon4d1d9832019-05-30 20:53:05 +000017The figure below shows the Artifacts (Blue) in the ONAP Policy Framework, the Activities (Yellow) that manipulate them,
18and important components (Salmon) that interact with them. The Policy Framework is fully TOSCA compliant, and uses
19TOSCA to model policies. Please see the :ref:`TOSCA Policy Primer <tosca-label>` page for an introduction to TOSCA
20policy concepts.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040021
liamfallon4d1d9832019-05-30 20:53:05 +000022.. image:: images/APIsInPolicyFramework.svg
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040023
liamfallon4d1d9832019-05-30 20:53:05 +000024TOSCA defines the concept of a *PolicyType*, the definition of a type of policy that can be applied to a service. It
25also defines the concept of a *Policy*, an instance of a *PolicyType*. In the Policy Framework, we handle and manage
26these TOSCA definitions and tie them to real implementations of policies that can run on PDPs.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040027
liamfallon4d1d9832019-05-30 20:53:05 +000028The diagram above outlines how this is achieved. Each TOSCA *PolicyType* must have a corresponding *PolicyTypeImpl* in
29the Policy FrameworkThe TOSCA *PolicyType* definition can be used to create a TOSCA *Policy* definition, either
30directly by the Policy Framework, by CLAMP, or by some other system. Once the *Policy* artifact exists, it can be used
31together with the *PolicyTypeImpl* artifact to create a *PolicyImpl* artifact. A *PolicyImpl* artifact is an executable
32policy implementation that can run on a PDP.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040033
liamfallon4d1d9832019-05-30 20:53:05 +000034The TOSCA *PolicyType* artifact defines the external characteristics of the policy; defining its properties, the types
35of entities it acts on, and its triggers A *PolicyTypeImpl* artifact is an XACML, Drools, or APEX implementation of
36that policy definition. *PolicyType* and *PolicyTypeImpl* artifacts may be preloaded, may be loaded manually, or may be
37created using the Lifecycle API. Alternatively, *PolicyType* definitions may be loaded over the Lifecycle API for
38preloaded *PolicyTypeImpl* artifacts. A TOSCA *PolicyType* artifact can be used by clients (such as CLAMP or CLI tools)
39to create, parse, serialize, and/or deserialize an actual Policy.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040040
liamfallon4d1d9832019-05-30 20:53:05 +000041The TOSCA *Policy* artifact is used internally by the Policy Framework, or is input by CLAMP or other systems. This
42artifact specifies the values of the properties for the policy and specifies the specific entities the policy acts on.
43Policy Design uses the TOSCA *Policy* artifact and the *PolicyTypeImpl* artifact to create an executable *PolicyImpl*
44artifact
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040045
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040046ONAP Policy Types
47=================
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040048
liamfallon4d1d9832019-05-30 20:53:05 +000049Policy Type Design manages TOSCA *PolicyType* artifacts and their *PolicyTypeImpl* implementations.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040050
liamfallon4d1d9832019-05-30 20:53:05 +000051A TOSCA *PolicyType* may ultimately be defined by the modeling team but for now are defined by the Policy Framework
52project. Various editors and GUIs are available for creating *PolicyTypeImpl* implementations. However, systematic
53integration of *PolicyTypeImpl* implementation is outside the scope of the ONAP Dublin release.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040054
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040055The *PolicyType* definitions and implementations listed below can be preloaded so that they are available for use in the
56Policy Framework upon platform installation. For a full listing of available preloaded policy types, see the
57:ref:`Policy API Preloaded Policy Type List <policy-preload-label>`.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040058
Pamela Dragosh08cc8422020-05-07 15:29:17 -040059============================================ ===============================================================================
60**Base Policy Types** **Description**
61============================================ ===============================================================================
62onap.policies.Monitoring Base model that supports Policy driven DCAE microservice components used
63 in Control Loops
Pamela Dragosh08cc8422020-05-07 15:29:17 -040064onap.policies.controlloop.operational.Common Base Control Loop operational policy common definitions
65onap.policies.controlloop.guard.Common Control Loop Guard Policy common definitions
66onap.policies.Optimization Base OOF Optimization Policy Type definition
67onap.policies.Naming Base SDNC Naming Policy Type definition
68onap.policies.Native Base Native Policy Type for PDPs to inherit from in order to provide their own
69 native policy type.
70============================================ ===============================================================================
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040071
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040072.. note::
73 The El Alto onap.policies.controlloop.Guard policy types were deprecated and removed in Frankfurt.
74
751 Base Policy Type: onap.policies.Monitoring
76--------------------------------------------
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040077
liamfallon4d1d9832019-05-30 20:53:05 +000078This is a base Policy Type that supports Policy driven DCAE microservice components used in a Control Loops. The
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040079implementation of this Policy Type is done in the XACML PDP. The :ref:`Decision API <decision-api-label>` is used by the DCAE
80Policy Handler to retrieve a decision on which policy to enforce during runtime.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040081
liamfallon4d1d9832019-05-30 20:53:05 +000082.. code-block:: yaml
83 :caption: Base Policy Type definition for onap.policies.Monitoring
84 :linenos:
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040085
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040086 tosca_definitions_version: tosca_simple_yaml_1_1_0
liamfallon4d1d9832019-05-30 20:53:05 +000087 topology_template:
88 policy_types:
89 - onap.policies.Monitoring:
90 derived_from: tosca.policies.Root
91 version: 1.0.0
92 description: a base policy type for all policies that govern monitoring provision
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040093
liamfallon4d1d9832019-05-30 20:53:05 +000094The *PolicyTypeImpl* implementation of the *onap.policies.Montoring* Policy Type is generic to support definition of
95TOSCA *PolicyType* artifacts in the Policy Framework using the Policy Type Design API. Therefore many TOSCA *PolicyType*
96artifacts will use the same *PolicyTypeImpl* implementation with different property types and towards different targets.
97This allows dynamically generated DCAE microservice component Policy Types to be created at Design Time.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -040098
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -040099Please be sure to name your Policy Type appropriately by prepending it with **onap.policies.monitoring.Custom**.
100Notice the lowercase **m** for monitoring, which follows TOSCA conventions. And also notice the capitalized "C" for
101your analytics policy type name.
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -0400102
liamfallon4d1d9832019-05-30 20:53:05 +0000103.. code-block:: yaml
104 :caption: Example PolicyType *onap.policies.monitoring.MyDCAEComponent* derived from *onap.policies.Monitoring*
105 :linenos:
Pamela Dragosh5fc2fdb2019-05-17 09:42:27 -0400106
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400107 tosca_definitions_version: tosca_simple_yaml_1_1_0
liamfallon4d1d9832019-05-30 20:53:05 +0000108 policy_types:
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400109 - onap.policies.monitoring.Mycomponent:
liamfallon4d1d9832019-05-30 20:53:05 +0000110 derived_from: onap.policies.Monitoring
111 version: 1.0.0
112 properties:
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400113 my_property_1:
114 type: string
115 description: A description of this property
liamfallon4d1d9832019-05-30 20:53:05 +0000116
117For more examples of monitoring policy type definitions, please refer to the examples in the `ONAP policy-models gerrit
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400118repository <https://github.com/onap/policy-models/tree/master/models-examples/src/main/resources/policytypes>`__. Please
119note that some of the examples do not adhere to TOSCA naming conventions due to backward compatibility.
liamfallon4d1d9832019-05-30 20:53:05 +0000120
liamfallon4d1d9832019-05-30 20:53:05 +0000121
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04001222 Base Policy Type onap.policies.controlloop.operational.Common
123---------------------------------------------------------------
124This is the new Operational Policy Type introduced in Frankfurt release to fully support TOSCA Policy Type. There are common
125properties and datatypes that are independent of the PDP engine used to enforce this Policy Type.
liamfallon4d1d9832019-05-30 20:53:05 +0000126
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400127.. image:: images/Operational.svg
128 :alt: Operational Policy Type Inheritance
liamfallon4d1d9832019-05-30 20:53:05 +0000129
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04001302.1 onap.policies.controlloop.operational.common.Drools
131~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liamfallon4d1d9832019-05-30 20:53:05 +0000132
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400133Drools PDP Control Loop Operational Policy definition extends the base common policy type by adding a property for **controllerName**.
liamfallon4d1d9832019-05-30 20:53:05 +0000134
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400135Please see the definition of the `Drools Operational Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml>`_
liamfallon4d1d9832019-05-30 20:53:05 +0000136
liamfallon4d1d9832019-05-30 20:53:05 +0000137
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04001382.2 onap.policies.controlloop.operational.common.Apex
139~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liamfallon4d1d9832019-05-30 20:53:05 +0000140
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400141Apex PDP Control Loop Operational Policy definition extends the base common policy type by adding additional properties.
liamfallon4d1d9832019-05-30 20:53:05 +0000142
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400143Please see the definition of the `Apex Operational Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml>`_
liamfallon4d1d9832019-05-30 20:53:05 +0000144
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04001453 Base Policy Type: onap.policies.controlloop.guard.Common
146----------------------------------------------------------
liamfallon4d1d9832019-05-30 20:53:05 +0000147
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400148This base policy type is the the type definition for Control Loop guard policies for frequency limiting, blacklisting and
liamfallon4d1d9832019-05-30 20:53:05 +0000149min/max guards to help protect runtime Control Loop Actions from doing harm to the network. This policy type is
150developed using the XACML PDP to support question/answer Policy Decisions during runtime for the Drools and APEX
151onap.controlloop.Operational policy type implementations.
152
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400153.. image:: images/Guard.svg
154 :alt: Guard Policy Type Inheritance
liamfallon4d1d9832019-05-30 20:53:05 +0000155
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400156Please see the definition of the `Common Guard Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Common.yaml>`_
157
1583.1 Frequency Limiter Guard onap.policies.controlloop.guard.common.FrequencyLimiter
159~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
161The frequency limiter supports limiting the frequency of actions being taken by an Actor.
162
163Please see the definition of the `Guard Frequency Limiter Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml>`_
164
1653.2 Min/Max Guard onap.policies.controlloop.guard.common.MinMax
166~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167
168The Min/Max Guard supports Min/Max number of entity for scaling operations.
169
170Please see the definition of the `Guard Min/Max Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml>`_
171
1723.3 Blacklist Guard onap.policies.controlloop.guard.common.Blacklist
173~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174
175The Blacklist Guard Supports blacklisting control loop actions from being performed on specific entity id's.
176
177Please see the definition of the `Guard Blacklist Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml>`_
178
Pamela Dragoshcc6265e2020-08-21 10:53:44 -04001793.4 Filter Guard onap.policies.controlloop.guard.common.Filter
180~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
182The Filter Guard Supports filtering control loop actions from being performed on specific entity id's.
183
184Please see the definition of the `Guard Filter Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.Filter.yaml>`_
185
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04001864 Optimization onap.policies.Optimization
187-----------------------------------------
188
189The Optimization Base Policy Type supports the OOF optimization policies. The Base policy Type has common properties shared
190by all its derived policy types.
191
192.. image:: images/Optimization.svg
193 :alt: Optimization Policy Type Inheritance
194
195Please see the definition of the `Base Optimization Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml>`_.
196
197These Policy Types are unique in that some properties have an additional metadata property **matchable** set to **true**
198which indicates that this property can be used to support more fine-grained Policy Decisions. For more information,
199see the :ref:`XACML Optimization application implementation <xacml-optimization-label>`.
200
2014.1 Optimization Service Policy Type onap.policies.optimization.Service
202~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203
204This policy type further extends the base onap.policies.Optimization type by defining additional properties specific to
205a service. For more information:
206
207`Service Optimization Base Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml>`_
208
209Several additional policy types inherit from the Service Optimization Policy Type. For more information, :ref:`XACML Optimization
210application implementation <xacml-optimization-label>`.
211
2124.2 Optimization Resource Policy Type onap.policies.optimization.Resource
213~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214
215This policy type further extends the base onap.policies.Optimization type by defining additional properties specific to
216a resource. For more information:
217
218`Resource Optimization Base Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml>`_
219
220Several additional policy types inherit from the Resource Optimization Policy Type. For more information, :ref:`XACML Optimization
221application implementation <xacml-optimization-label>`.
222
2235 Naming onap.policies.Naming
224-----------------------------
225
226Naming policies are used in SDNC to enforce which naming policy should be used during instantiation.
227
228Policies of this type are composed using the `Naming Policy Type Model <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.Naming.yaml>`_.
229
2306 Native Policy Types onap.policies.Native
231------------------------------------------
232
233This is the Base Policy Type used by PDP engines to support their native language policies. PDP engines inherit from
234this base policy type to implement support for their own custom policy type:
235
236.. code-block:: yaml
237
238 tosca_definitions_version: tosca_simple_yaml_1_1_0
liamfallon4d1d9832019-05-30 20:53:05 +0000239 policy_types:
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400240 onap.policies.Native:
241 derived_from: tosca.policies.Root
242 description: a base policy type for all native PDP policies
243 version: 1.0.0
liamfallon4d1d9832019-05-30 20:53:05 +0000244
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04002456.1 Policy Type: onap.policies.native.drools.Controller
246~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jhh89ba0972020-04-13 12:51:32 -0500247
248This policy type supports creation of native PDP-D controllers via policy. A controller is an abstraction on
249the PDP-D that groups communication channels, message mapping rules, and
250any other arbitrary configuration data to realize an application.
251
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400252Policies of this type are composed using the
jhh89ba0972020-04-13 12:51:32 -0500253`onap.policies.native.drools.Controller policy type specification
254<https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml>`__ specification.
255
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04002566.2 Policy Type: onap.policies.native.drools.Artifact
257~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jhh89ba0972020-04-13 12:51:32 -0500258
259This policy type supports the dynamic association of a native PDP-D controller with rules and dependent
260java libraries. This policy type is used in conjuction with the onap.policies.native.drools.Controller
261type to create or upgrade a drools application on a live PDP-D.
262
263Policies of this type are composed against the
264`onap.policies.native.drools.Controller policy type specification
265<https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml>`__ specification.
266
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04002676.3 Policy Type: onap.policies.native.Xacml
268~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liamfallon4d1d9832019-05-30 20:53:05 +0000269
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400270This policy type supports XACML OASIS 3.0 XML Policies. The policies are URL encoded in order to be easily transported via Lifecycle
271API json and yaml Content-Types. When deployed to the XACML PDP (PDP-X), they will be managed by the **native** application. The PDP-X
272will route XACML Request/Response RESTful API calls to the **native** application who manages those decisions.
liamfallon4d1d9832019-05-30 20:53:05 +0000273
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400274`XACML Native Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.native.Xacml.yaml>`_
liamfallon4d1d9832019-05-30 20:53:05 +0000275
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -04002766.4 Policy Type: onap.policies.native.Apex
277~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liamfallon4d1d9832019-05-30 20:53:05 +0000278
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400279This policy type supports Apex native policy types.
liamfallon4d1d9832019-05-30 20:53:05 +0000280
Pamela Dragoshf65c8ff2020-04-29 08:23:12 -0400281`Apex Native Policy Type <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policytypes/onap.policies.native.Apex.yaml>`_