blob: 0e1b88b80749f7d805079c242034f72f6f47d8cd [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with Policy. It handles low level stuff like managing the http request library and Policy required fields
DR695Hccff30b2017-02-17 18:44:24 -05003Library RequestsLibrary
4Library String
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +02005Library Collections
DR695H910097e2019-05-08 13:55:32 -04006Library SSHLibrary
7Library OperatingSystem
DR695Hd9794652019-07-19 18:20:40 -04008Library ONAPLibrary.Templating WITH NAME Templating
DR695Hccff30b2017-02-17 18:44:24 -05009Resource global_properties.robot
DR695H910097e2019-05-08 13:55:32 -040010Resource ssh/files.robot
DR695Hccff30b2017-02-17 18:44:24 -050011
12*** Variables ***
mrichommed7855e22020-04-07 17:03:46 +020013${POLICY_NEW_HEALTHCHECK_PATH} /policy/pap/v1/components/healthcheck
mrichomme455d3992020-04-03 14:56:40 +020014${POLICY_NEW_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
DR695H34409422019-06-20 10:56:46 -040015${POLICY_TEMPLATES} policy
Bilal A461aa5b2019-05-06 14:00:57 -040016${POLICY_API_IP} ${GLOBAL_INJECTED_POLICY_API_IP_ADDR}
17${POLICY_PAP_IP} ${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR}
Bilal A461aa5b2019-05-06 14:00:57 -040018${POLICY_PDPX_IP} ${GLOBAL_INJECTED_POLICY_PDPX_IP_ADDR}
Bilal A461aa5b2019-05-06 14:00:57 -040019${POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_USERNAME}
20${POLICY_HEALTHCHECK_PASSWORD} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD}
Nagendra9028704889532020-09-04 15:44:45 +053021${json_path_policy} /var/opt/ONAP/robot/assets/policy/
22${POLICY_GET_POLICY_URI} /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0
23${POLICY_CREATE_POLICY_URI} /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies
DR695Hccff30b2017-02-17 18:44:24 -050024
Brian Freeman88fbb992019-05-17 17:46:56 -050025
DR695Hccff30b2017-02-17 18:44:24 -050026*** Keywords ***
27
28Run Policy Health Check
Pamela Dragosh0adce512020-08-25 13:18:02 -040029 [Documentation] Runs Policy Health Check
mrichomme455d3992020-04-03 14:56:40 +020030 ${auth}= Create List ${GLOBAL_POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD}
31 Log Creating session ${POLICY_NEW_HEALTHCHECK_ENDPOINT}
32 ${session}= Create Session policy ${POLICY_NEW_HEALTHCHECK_ENDPOINT} auth=${auth}
33 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
mrichommed7855e22020-04-07 17:03:46 +020034 ${resp}= Get Request policy ${POLICY_NEW_HEALTHCHECK_PATH} headers=${headers}
mrichomme455d3992020-04-03 14:56:40 +020035 Log Received response from policy ${resp.text}
36 Should Be Equal As Strings ${resp.status_code} 200
37 Should Be True ${resp.json()['healthy']}
38
Brian Freeman55b96e22019-05-08 20:49:45 -050039Run Policy Pap Get Request
40 [Documentation] Runs Policy Pap Get request
41 [Arguments] ${data_path}
42 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
43 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020044 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050045 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
46 ${resp}= Get Request policy ${data_path} headers=${headers}
47 Log Received response from Policy Pap ${resp.text}
48 [Return] ${resp}
49
Brian Freeman64c82052020-12-08 09:14:37 -050050Run Policy Api Get Request
51 [Documentation] Runs Policy Api Get request
52 [Arguments] ${data_path}
53 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
54 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
55 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
56 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
57 ${resp}= Get Request policy ${data_path} headers=${headers}
58 Log Received response from policy API ${resp.text}
59 [Return] ${resp}
60
Brian Freeman55b96e22019-05-08 20:49:45 -050061Run Policy Api Post Request
62 [Documentation] Runs Policy Api Post request
63 [Arguments] ${data_path} ${data}
64 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020065 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050066 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
67 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
68 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
69 Log Received response from policy ${resp.text}
70 [Return] ${resp}
71
Brian Freeman55b96e22019-05-08 20:49:45 -050072Run Policy Pap Post Request
73 [Documentation] Runs Policy Pap Post request
74 [Arguments] ${data_path} ${data}
75 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020076 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050077 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
78 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
79 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
80 Log Received response from policy ${resp.text}
81 [Return] ${resp}
82
Brian Freemane6c3d282019-09-30 14:20:02 -050083Undeploy Policy
84 [Documentation] Runs Policy PAP Undeploy a Policy from PDP Groups
85 [Arguments] ${policy_name}
86 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
87 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
88 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
89 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
90 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/${policy_name} headers=${headers}
91 Log Received response from policy ${resp.text}
a.sreekumar5dc8c142021-02-18 16:57:46 +000092 Should Be Equal As Strings ${resp.status_code} 202
Brian Freemane6c3d282019-09-30 14:20:02 -050093
Brian Freemanc967dd62019-04-30 09:47:44 -050094Update vVFWCL Policy
Brian Freeman0d866b52019-05-08 20:30:14 -050095 [Arguments] ${resource_id}
DR695H8e7028b2019-07-10 10:13:58 -040096 Log Create vFWCL Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -050097 Create vFirewall Monitoring Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -050098 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -040099 Log Create vFWCL Operational Policy
Brian Freeman75948282019-05-14 20:44:46 -0500100 ${op_policy_version}= Create vFirewall Operational Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -0500101 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -0400102 Log Push vFWCL To PDP Group
Brian Freeman75948282019-05-14 20:44:46 -0500103 Push vFirewall Policies To PDP Group ${op_policy_version}
Brian Freemanc967dd62019-04-30 09:47:44 -0500104 Sleep 20s
DR695H8e7028b2019-07-10 10:13:58 -0400105 Log Validate vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -0700106 Validate the vFWCL Policy
107
Brian Freeman55b96e22019-05-08 20:49:45 -0500108Validate the vFWCL Policy
109 ${resp}= Run Policy Pap Get Request /policy/pap/v1/pdps
Brian Freeman64c82052020-12-08 09:14:37 -0500110 Log Received response from policy PAP ${resp.text}
111 Should Be Equal As Strings ${resp.status_code} 200
112 ${resp}= Run Policy Api Get Request /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2
113 Log Received response from policy API policytypes ${resp.text}
Brian Freemanc967dd62019-04-30 09:47:44 -0500114 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemane14d2572019-04-29 16:20:21 -0500115
116Create vFirewall Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -0500117 [Arguments] ${resource_id}
118 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400119 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
120 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.jinja ${dict}
Pamela Dragosh0adce512020-08-25 13:18:02 -0400121 ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies ${data}
Brian Freemane14d2572019-04-29 16:20:21 -0500122 Should Be Equal As Strings ${resp.status_code} 200
123
Brian Freeman88fbb992019-05-17 17:46:56 -0500124Create vFirewall Operational Policy
DR695H34409422019-06-20 10:56:46 -0400125 [Arguments] ${resource_id}
126 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400127 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
Brian Freemandf0ca462020-05-06 15:10:06 -0500128 ${data_2}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_operational_content_input.jinja ${dict}
DR695H8e7028b2019-07-10 10:13:58 -0400129 Log ${data_2}
Brian Freemandf0ca462020-05-06 15:10:06 -0500130 ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies ${data_2}
DR695H34409422019-06-20 10:56:46 -0400131 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemandf0ca462020-05-06 15:10:06 -0500132 [Return] ${resp.json()['version']}
Brian Freeman88fbb992019-05-17 17:46:56 -0500133
Brian Freeman64c82052020-12-08 09:14:37 -0500134Update vFWCL Operational and Monitoring Policies
135 [Documentation] Undeploy, Delete and Create Operational and Monitoring policies for vFWCL
136 [Arguments] ${model_invariant_id}
137 Run Keyword And Ignore Error Run Undeploy vFW Monitoring Policy
mrichommed168a9a2020-12-16 10:24:33 +0100138 Run Keyword And Ignore Error Run Undeploy Policy
Brian Freeman64c82052020-12-08 09:14:37 -0500139 # Need to wait a little for undeploy
140 Validate the vFWCL Policy
141 Run Keyword and Ignore Error Run Delete vFW Monitoring Policy
142 Run Keyword And Ignore Error Run Delete vFW Operational Policy
143 Update vVFWCL Policy ${model_invariant_id}
144
Brian Freemane14d2572019-04-29 16:20:21 -0500145Push vFirewall Policies To PDP Group
DR695H34409422019-06-20 10:56:46 -0400146 [Arguments] ${op_policy_version}
147 ${dict}= Create Dictionary OP_POLICY_VERSION=${op_policy_version}
DR695Hd9794652019-07-19 18:20:40 -0400148 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
149 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_push.jinja ${dict}
DR695H34409422019-06-20 10:56:46 -0400150 ${resp}= Run Policy Pap Post Request /policy/pap/v1/pdps/policies ${data}
a.sreekumar5dc8c142021-02-18 16:57:46 +0000151 Should Be Equal As Strings ${resp.status_code} 202
Nagendra9028704889532020-09-04 15:44:45 +0530152
153Run Create Policy Post Request
154 [Documentation] Runs Create Policy Post request
155 #[Arguments] ${data}
156 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
157 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
158 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
159 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
160 ${json_policy} Get Binary File ${json_path_policy}create_policy.json
161 ${resp}= Post Request policy ${POLICY_CREATE_POLICY_URI} data=${json_policy} headers=${headers}
162 Log Received response from policy ${resp.text}
163 [Return] ${resp}
164 Should Be Equal As Strings ${resp.status_code} 200
165
166Run Get Policy Get Request
167 [Documentation] Runs Get Policy request
168 #[Arguments] ${data}
169 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
170 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
171 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
172 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
173 ${resp}= Get Request policy ${POLICY_GET_POLICY_URI} headers=${headers}
174 Log Received response from policy ${resp.text}
175 [Return] ${resp}
176 Should Be Equal As Strings ${resp.status_code} 200
177
178Run Deploy Policy Pap Post Request
179 [Documentation] Runs Deploy Policy Pap Post request
180 #[Arguments] ${data_path} ${data}
181 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
182 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
183 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
184 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
185 ${json_deploy} Get Binary File ${json_path_policy}deploy_policy.json
186 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${json_deploy} headers=${headers}
187 Log Received response from policy ${resp.text}
188 [Return] ${resp}
a.sreekumar5dc8c142021-02-18 16:57:46 +0000189 Should Be Equal As Strings ${resp.status_code} 202
Nagendra9028704889532020-09-04 15:44:45 +0530190
mrichommed168a9a2020-12-16 10:24:33 +0100191Run Undeploy Policy
Nagendra9028704889532020-09-04 15:44:45 +0530192 [Documentation] Runs Policy PAP Undeploy a Policy from PDP Groups
193 #[Arguments] ${policy_name}
194 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
195 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
196 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
197 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
198 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/operational.modifyconfig headers=${headers}
199 Log Received response from policy ${resp.text}
a.sreekumar5dc8c142021-02-18 16:57:46 +0000200 Should Be Equal As Strings ${resp.status_code} 202
Nagendra9028704889532020-09-04 15:44:45 +0530201
Brian Freeman64c82052020-12-08 09:14:37 -0500202Run Undeploy vFW Monitoring Policy
203 [Documentation] Runs Policy PAP Undeploy vFW Monitoring Policy from PDP Groups
204 #[Arguments] ${policy_name}
205 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
206 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
207 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
208 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
209 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.vfirewall.tca headers=${headers}
210 Log Received response from policy ${resp.text}
a.sreekumar5dc8c142021-02-18 16:57:46 +0000211 Should Be Equal As Strings ${resp.status_code} 202
Brian Freeman64c82052020-12-08 09:14:37 -0500212
213
214Run Delete vFW Monitoring Policy
215 [Documentation] Runs Policy API Undeploy a Monitoring Policy
216 #[Arguments] ${policy_name}
217 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
218 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
219 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
220 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
221 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.vfirewall.tca/versions/1.0.0 headers=${headers}
222 Log Received response from policy ${resp.text}
223 Should Be Equal As Strings ${resp.status_code} 200
224
Brian Freeman4e737eb2020-12-11 14:03:57 -0500225Run Delete vFW Operational Policy
226 [Documentation] Runs Policy API Delete Operational Policy
227 #[Arguments] ${policy_name}
228 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
229 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
230 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
231 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
232 ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0 headers=${headers}
233 Log Received response from policy ${resp.text}
234 Should Be Equal As Strings ${resp.status_code} 200
Nagendra9028704889532020-09-04 15:44:45 +0530235
236Run Delete Policy Request
237 [Documentation] Runs Policy Delete request
238 #[Arguments] ${data_path} ${data}
jhhb91ba0f2020-09-10 11:58:10 -0500239 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
240 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
241 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
242 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Nagendra9028704889532020-09-04 15:44:45 +0530243 ${resp}= Delete Request policy ${POLICY_GET_POLICY_URI} headers=${headers}
244 Log Received response from policy ${resp.text}
245 [Return] ${resp}
246 Should Be Equal As Strings ${resp.status_code} 200