blob: 2b44c468bfc9ad07690573e3ea0c6ac236232cfa [file] [log] [blame]
Saryu Shahb5ce8852017-11-02 00:56:03 +00001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4*********************************
5Creating and Using Guard Policies
6*********************************
7
8.. contents::
9 :depth: 3
10
11Background
12^^^^^^^^^^
13
14Guard policies are used to limit what operations shall be permitted. These policies are specified in the Policy GUI or restful API and either return "PERMIT" or "DENY" on request.
15
Saryu Shahd14620d2017-11-03 21:02:26 +000016There are 2 types of policies, guard policies and blacklist guard policies. The blacklist describes what is not allowed to be permitted and guard policies describe what is allowed to be permitted. The Policy PDP behaves in a PERMIT overrides fashion, that is, if any policy permits, it will override any denies.
17
18.. note:: *Limit Functionality*: The determination to deny a request because it has exceeded the limit is based on the number of entries in the **database**.
Saryu Shahb5ce8852017-11-02 00:56:03 +000019
20Creating Guard Policies
21^^^^^^^^^^^^^^^^^^^^^^^
22
23There are two options for creating guard policies: (1) through the GUI and (2) through the restful API.
24
25GUI Method
26----------
27
28The GUARD policy can be created from the POLICY GUI as shown below.
29
Saryu Shahb5ce8852017-11-02 00:56:03 +000030.. image:: PolicyGUI_GuardPolicy.png
31
Saryu Shah09359092018-08-18 01:06:37 +000032In a Blacklist policy, the blacklist entries can be entered either manually or imported from an excel sheet. This import option can also be used to delete existing blacklist entries and to add new entries.
33
34.. image:: PolicyGUI_BlacklistPolicy.png
35
Saryu Shahb5ce8852017-11-02 00:56:03 +000036
37API Method
38----------
39
Saryu Shahd14620d2017-11-03 21:02:26 +000040To create the policy, use the PUT /createPolicy API. This request uses Basic Access Authentication.
41
42The request should be in the following form for the regular guard policy:
Saryu Shahb5ce8852017-11-02 00:56:03 +000043
Saryu Shah73009de2017-11-02 16:59:23 +000044.. code-block:: json
Saryu Shahb5ce8852017-11-02 00:56:03 +000045 :caption: Regular Guard Policy Creation
46 :linenos:
47
48 {
49 "policyClass": "Decision",
50 "policyName": "Test.TestingGUARDapitest",
51 "policyDescription": "Testing new YAML Guard Policy",
52 "onapName": "PDPD",
53 "ruleProvider": "GUARD_YAML",
54 "attributes": {
55 "MATCHING": {
56 "actor": "APPC",
57 "recipe": "restart",
58 "targets" : "test",
59 "clname" : "test",
60 "limit": "5",
61 "timeWindow": "15",
62 "timeUnits" : "minute",
63 "guardActiveStart": "05:00:00-05:00",
64 "guardActiveEnd": "23:59:59-05:00"
65 }
66 }
67 }
68
Michael Mokrye957a1d2018-09-10 15:23:15 -050069The request should be in the following form for the Min/Max guard policy:
70
71.. code-block:: json
72 :caption: Min/Max Guard Policy Creation
73 :linenos:
74
75 {
76 "policyClass": "Decision",
77 "policyName": "Test.TestingGUARDMinMaxtest",
78 "policyDescription": "Testing new Min/Max Guard Policy",
79 "onapName": "PDPD",
80 "ruleProvider": "GUARD_MIN_MAX",
81 "attributes": {
82 "MATCHING": {
83 "actor": "SO",
84 "recipe": "scaleOut",
85 "targets" : ".*",
86 "clname" : "test",
87 "min": "1",
88 "max": "5",
89 "guardActiveStart": "05:00:00-05:00",
90 "guardActiveEnd": "23:59:59-05:00"
91 }
92 }
93 }
94
Saryu Shahb5ce8852017-11-02 00:56:03 +000095The request should be in the following form for blacklist guard policy:
96
Saryu Shah73009de2017-11-02 16:59:23 +000097.. code-block:: json
Saryu Shahb5ce8852017-11-02 00:56:03 +000098 :caption: Blacklist Guard Policy Creation
99 :linenos:
100
101 {
102 "policyClass": "Decision",
103 "policyName": "Test.TestingBLGUARD",
104 "policyDescription": "Testing New BL YAML Guard Policy",
105 "onapName": "MSO",
106 "ruleProvider": "GUARD_BL_YAML",
107 "attributes": {
108 "MATCHING": {
109 "actor": "APPC",
110 "recipe": "restart",
111 "clname": "test",
112 "guardActiveStart": "05:00:00-05:00",
113 "guardActiveEnd": "23:59:59-05:00",
114 "blackList": "target1,target2,target3"
115 }
116 }
117 }
118
119Using Guard Policies
120^^^^^^^^^^^^^^^^^^^^
121
122In order to use the guard policies just make an http request. For example:
123
124.. code-block:: bash
125
126 http
127 POST pdp:8081/pdp/api/getDecision
128 Authorization:<yourAuth> ClientAuth:<yourClientAuth>
129 Environment:<environment> Content-Type:application/json < guard_request.json
130
131| where:
Saryu Shah73009de2017-11-02 16:59:23 +0000132| *<yourAuth>* is the string generated from user:pass converted to base64 encoding.
133| *<yourClientAuth>* is generated the same way but from the client user and pass.
134| *<environment>* is the context of the request. For example: TEST
Saryu Shahb5ce8852017-11-02 00:56:03 +0000135
136The guard_request.json should be in the form of the following:
137
138.. code-block:: json
139 :caption: guard_request.json
140
141 {
142 "decisionAttributes": {
143 "actor": "APPC",
144 "recipe": "Restart",
145 "target": "test13",
Michael Mokrye957a1d2018-09-10 15:23:15 -0500146 "clname" : "piptest",
147 "vfCount" : "4"
Saryu Shahb5ce8852017-11-02 00:56:03 +0000148 },
149 "onapName": "PDPD"
150 }
151
Saryu Shahd14620d2017-11-03 21:02:26 +0000152A response containing a PERMIT or DENY in uppercase is returned as follows:
Saryu Shahb5ce8852017-11-02 00:56:03 +0000153
154.. code-block:: json
155 :caption: Response
156
157 {
158 "decision": "PERMIT",
159 "details": "Decision Permit. OK!"
160 }
161
162
Saryu Shah4300d572017-11-02 13:13:59 +0000163End of Document
Saryu Shahb5ce8852017-11-02 00:56:03 +0000164
Saryu Shah83f3ae32017-11-06 23:18:08 +0000165.. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Creating+and+Using+Guard+Policies
166
167