Fixed typo in clsimulation.rst
[policy/engine.git] / docs / platform / clsimulation.rst
1
2 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
4
5 **********************************************************
6 Control Loop Simulation and Injection of Messages Overview 
7 **********************************************************
8
9 .. contents::
10     :depth: 3
11
12 Telemetry
13 ^^^^^^^^^
14 The username and password for the Telemetry commands are in *${POLCIY_HOME}/config/policy-engine.properties*.
15
16 Injecting messages:
17 -------------------
18
19 To inject messages use the following command.  The injected message will look as if it came in from the specified topic and will be processed accordingly.
20
21 Use the command:
22
23     .. code-block:: bash
24
25         http -a <userName>:<password> PUT :9696/policy/pdp/engine/topics/sources/ueb/<topic>/events @<onsetFile> Content-Type:"text/plain"
26
27 Alternatively, this command could be used:
28
29     .. code-block:: bash
30
31         curl --silent --user <userName>:<password> -X PUT --header "Content-Type: text/plain" –data @<onsetFile> http://localhost:9696/policy/pdp/engine/topics/sources/ueb/<topic>/events
32
33 The topic beeing used is *unauthenticated.DCAE_CL_OUTPUT*, which is subject to change.  The onset file is a file that contains the data to inject as the onset.  The data contained depends on the use case. This is an example for VoLTE:
34
35     .. code-block:: json
36        :caption: VoLTE_Sample_Onset
37
38         {
39             "closedLoopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",
40             "closedLoopAlarmStart": 1484677482204798,
41             "closedLoopEventClient": "DCAE.HolmesInstance",
42             "closedLoopEventStatus": "ONSET",
43             "requestID": "97964e10-686e-4790-8c45-bdfa61df770f",
44             "target_type": "VM",
45             "target": "vserver.vserver-name",
46             "AAI": {
47                 "vserver.is-closed-loop-disabled": "false",
48                 "vserver.vserver-name": "dfw1lb01lb01",
49                 "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1",
50                 "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1",
51                 "generic-vnf.vnf-name" : "vnf-name-16102016-aai3255-data-11-1"
52             },
53             "from": "DCAE",
54             "version": "1.0.2"
55         }
56
57 Getting Information 
58 -------------------
59
60 To get the name of the controller(s) active, use:
61
62     .. code-block:: bash
63
64         curl --silent --user <username>:<password> -X GET http://localhost:9696/policy/pdp/engine/controllers | python -m json.tool
65
66 To check the facts currently in memory, use the following command.  There should be 1 each of org.onap.policy.controlloop.PapParams and org.onap.policy.controlloop.Params per policy pushed.
67
68     .. code-block:: bash
69
70         curl --silent --user <username>:<password> -X GET http://localhost:9696/policy/pdp/engine/controllers/<controllerName>/drools/facts/<artifactId> | python -m json.tool
71
72 To get additional information about the controller, use:
73
74     .. code-block:: bash
75
76         curl --silent --user <username>:<password> -X GET http://localhost:9696/policy/pdp/engine/controllers/<controllerName> | python -m json.tool
77
78
79 Simulators
80 ^^^^^^^^^^
81
82 Currently, there are 4 supported simulators: A&AI, SO, vFC, and guard.  When they are up, they are accessed via localhost on the following ports: A&AI – 6666, SO – 6667, vFC – 6668, and guard – 6669.  They all respond with hard-coded values representing their various success messages except for with certain inputs.  For the A&AI simulator, if the value being queried with a “GET” query is “getFail” the simulator returns an exception message, if the value being queried in a “GET” query is “disableClosedLoop” the simulator returns a response with the value of “is-closed-loop-disabled” set to true, and if the value being queried in a named query is “error” the response from the simulator is A&AI’s failure message.  The other simulator that can return multiple response is the guard simulator, and that returns a deny response if the closed loop control name passed in is “denyGuard” 
83
84 Using the Simulators
85 --------------------
86
87 To check the status of the simulators, run the command: "*features status*".  If the feature controlloop-utils is enabled, the simulators are being used, otherwise, they are not.
88
89 **Turning on the simulators**
90
91     - First, make sure the controller is off by running the command “*policy stop*”. 
92     - Then turn the feature on with the command “*features enable controlloop-utils*”.  
93     - Finally restart the controller by running “*policy start*”.  
94     - Run “*features status*” again and the *feature controlloop-utils* will be **enabled**.
95
96 **Turning the simulators off**
97
98     - First, make sure the controller is off by running the command “*policy stop*”. 
99     - Then turn the feature off with the command “*features disable controlloop-utils*”.
100     - Finally restart the controller by running “*policy start*”.  
101     - Run “*features status*” again and the *feature controlloop-utils* will be **disabled**.
102
103 **For Junits**
104
105     For Junits, the package *org.onap.policy.simulators* is neeeded.  In the Util class, there are four methods to start the four different simulators: *buildAaiSim()*, *buildSoSim()*, *buildVfcSim()*, and *buildGuardSim()*.  Once the method is called, the simulator should be up and waiting to respond to requests.  To bring down the simulators, call *HttpServletServer.factory.destroy()*.
106
107 Responses
108 ---------
109
110 **A&AI**
111
112     .. code-block:: bash
113        :caption: vnf-GET-response
114
115         {
116          "vnf-id": vnfId, //vnfId will be the vnfId you query on.  If you query on a vnfName, the id will be "error" if the name is "error", "5e49ca06-2972-4532-9ed4-6d071588d792" otherwise
117          "vnf-name": vnfName, //vnfName will be the vnfName you query on.  If you query on a vnfId, the name will be "USUCP0PCOIL0110UJRT01"
118          "vnf-type": "RT",
119          "service-id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
120          "equipment-role": "UCPE",
121          "orchestration-status": "created",
122          "management-option": "ATT",
123          "ipv4-oam-address": "32.40.68.35",
124          "ipv4-loopback0-address": "32.40.64.57",
125          "nm-lan-v6-address": "2001:1890:e00e:fffe::1345",
126          "management-v6-address": "2001:1890:e00e:fffd::36",
127          "in-maint": false,
128          "is-closed-loop-disabled": isDisabled, //isDisabled will be true if the vnf name/Id you query on is disableClosedLoop, false otherwise
129          "resource-version": "1493389458092",
130         
131          "relationship-list": {
132           "relationship": [{
133            "related-to": "service-instance",
134            "related-link": "/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01",
135            "relationship-data": [{
136             "relationship-key": "customer.global-customer-id",
137             "relationship-value": "1610_Func_Global_20160817084727"
138            }, {
139             "relationship-key": "service-subscription.service-type",
140             "relationship-value": "uCPE-VMS"
141            }, {
142             "relationship-key": "service-instance.service-instance-id",
143             "relationship-value": "USUCP0PCOIL0110UJZZ01"
144            }],
145            "related-to-property": [{
146             "property-key": "service-instance.service-instance-name"
147            }]
148           }, {
149            "related-to": "vserver",
150            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45",
151            "relationship-data": [{
152             "relationship-key": "cloud-region.cloud-owner",
153             "relationship-value": "att-aic"
154            }, {
155             "relationship-key": "cloud-region.cloud-region-id",
156             "relationship-value": "AAIAIC25"
157            }, {
158             "relationship-key": "tenant.tenant-id",
159             "relationship-value": "USUCP0PCOIL0110UJZZ01::uCPE-VMS"
160            }, {
161             "relationship-key": "vserver.vserver-id",
162             "relationship-value": "3b2558f4-39d8-40e7-bfc7-30660fb52c45"
163            }],
164            "related-to-property": [{
165             "property-key": "vserver.vserver-name",
166             "property-value": "USUCP0PCOIL0110UJZZ01-vsrx"
167            }]
168           }]
169          }
170
171
172     .. code-block:: bash
173        :caption: vnf-GET-fail
174
175         //This is returned if you query on the value "getFail"
176         {
177          "requestError": {
178           "serviceException": {
179            "messageId": "SVC3001",
180            "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
181            "variables": ["GET", "network/generic-vnfs/generic-vnf/getFail", "Node Not Found:No Node of type generic-vnf found at network/generic-vnfs/generic-vnf/getFail", "ERR.5.4.6114"]
182           }
183          }
184         }
185
186
187     .. code-block:: bash
188        :caption: vserver-GET-response
189
190         {
191          "vserver": [{
192           "vserver-id": "d0668d4f-c25e-4a1b-87c4-83845c01efd8",
193           "vserver-name": vserverName, // The value you query on
194           "vserver-name2": "vjunos0",
195           "vserver-selflink": "https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8",
196           "in-maint": false,
197           "is-closed-loop-disabled": isDisabled, // True if the vserverName is "disableClosedLoop", false otherwise
198           "resource-version": "1494001931513",
199           "relationship-list": {
200            "relationship": [{
201             "related-to": "generic-vnf",
202             "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/e1a41e99-4ede-409a-8f9d-b5e12984203a",
203             "relationship-data": [{
204              "relationship-key": "generic-vnf.vnf-id",
205              "relationship-value": "e1a41e99-4ede-409a-8f9d-b5e12984203a"
206             }],
207             "related-to-property": [{
208              "property-key": "generic-vnf.vnf-name",
209              "property-value": "USMSO1SX7NJ0103UJSW01"
210             }]
211            }, {
212             "related-to": "pserver",
213             "related-link": "/aai/v11/cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01",
214             "relationship-data": [{
215              "relationship-key": "pserver.hostname",
216              "relationship-value": "USMSO1SX7NJ0103UJZZ01"
217             }],
218             "related-to-property": [{
219              "property-key": "pserver.pserver-name2"
220             }]
221            }]
222           }
223          }]
224         }
225
226
227     .. code-block:: bash
228        :caption: vserver-GET-error
229
230         //This is returned if you query on the value "getFail"
231         {
232          "requestError": {
233           "serviceException": {
234            "messageId": "SVC3001",
235            "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
236            "variables": ["GET", "nodes/vservers", "Node Not Found:No Node of type generic-vnf found at nodes/vservers", "ERR.5.4.6114"]
237           }
238          }
239         }
240
241
242     .. code-block:: bash
243        :caption: vnf-NamedQuery-response
244
245         {
246          "inventory-response-item": [{
247           "model-name": "service-instance",
248           "generic-vnf": {
249            "vnf-id": vnfID, // This will be the vnfID you query on
250            "vnf-name": "ZRDM2MMEX39",
251            "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
252            "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
253            "orchestration-status": "active",
254            "in-maint": false,
255            "is-closed-loop-disabled": false,
256            "resource-version": "1503082370097",
257            "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
258            "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
259           },
260           "extra-properties": {},
261           "inventory-response-items": {
262            "inventory-response-item": [{
263             "model-name": "service-instance",
264             "service-instance": {
265              "service-instance-id": "37b8cdb7-94eb-468f-a0c2-4e3c3546578e",
266              "service-instance-name": "Changed Service Instance NAME",
267              "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
268              "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9",
269              "resource-version": "1503082993532",
270              "orchestration-status": "Active"
271             },
272             "extra-properties": {},
273             "inventory-response-items": {
274              "inventory-response-item": [{
275               "model-name": "pnf",
276               "generic-vnf": {
277                "vnf-id": "jimmy-test",
278                "vnf-name": "jimmy-test-vnf",
279                "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
280                "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
281                "orchestration-status": "active",
282                "in-maint": false,
283                "is-closed-loop-disabled": false,
284                "resource-version": "1504013830207",
285                "model-invariant-id": "862b25a1-262a-4961-bdaa-cdc55d69785a",
286                "model-version-id": "e9f1fa7d-c839-418a-9601-03dc0d2ad687"
287               },
288               "extra-properties": {}
289              }, {
290               "model-name": "service-instance",
291               "generic-vnf": {
292                "vnf-id": "jimmy-test-vnf2",
293                "vnf-name": "jimmy-test-vnf2-named",
294                "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
295                "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
296                "orchestration-status": "active",
297                "in-maint": false,
298                "is-closed-loop-disabled": false,
299                "resource-version": "1504014833841",
300                "model-invariant-id": "Eace933104d443b496b8.nodes.heat.vpg",
301                "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
302               },
303               "extra-properties": {}
304              }]
305             }
306            }]
307           }
308          }]
309         }
310
311
312     .. code-block:: bash
313        :caption: vserver-NamedQuery-response
314
315         {
316          "inventory-response-item": [{
317           "extra-properties": {},
318           "inventory-response-items": {
319            "inventory-response-item": [{
320             "extra-properties": {
321              "extra-property": [{
322               "property-name": "model-ver.model-version-id",
323               "property-value": "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"
324              }, {
325               "property-name": "model-ver.model-name",
326               "property-value": "generic-vnf"
327              }, {
328               "property-name": "model.model-type",
329               "property-value": "widget"
330              }, {
331               "property-name": "model.model-invariant-id",
332               "property-value": "acc6edd8-a8d4-4b93-afaa-0994068be14c"
333              }, {
334               "property-name": "model-ver.model-version",
335               "property-value": "1.0"
336              }]
337             },
338             "generic-vnf": {
339              "in-maint": false,
340              "is-closed-loop-disabled": false,
341              "model-invariant-id": "acc6edd8-a8d4-4b93-afaa-0994068be14c",
342              "model-version-id": "93a6166f-b3d5-4f06-b4ba-aed48d009ad9",
343              "orchestration-status": "Created",
344              "resource-version": "1507826325834",
345              "service-id": "b3f70641-bdb9-4030-825e-6abb73a1f929",
346              "vnf-id": "594e2fe0-48b8-41ff-82e2-3d4bab69b192",
347              "vnf-name": "Vnf_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8",
348              "vnf-type": "8330e932-2a23-4943-8606/c15ce9e1-e914-4c8f-b8bb 1"
349             },
350             "inventory-response-items": {
351              "inventory-response-item": [{
352               "extra-properties": {
353                "extra-property": [{
354                 "property-name": "model-ver.model-version-id",
355                 "property-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
356                }, {
357                 "property-name": "model-ver.model-name",
358                 "property-value": "service-instance"
359                }, {
360                 "property-name": "model.model-type",
361                 "property-value": "widget"
362                }, {
363                 "property-name": "model.model-invariant-id",
364                 "property-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
365                }, {
366                 "property-name": "model-ver.model-version",
367                 "property-value": "1.0"
368                }]
369               },
370               "model-name": "service-instance",
371               "service-instance": {
372                "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
373                "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9",
374                "resource-version": "1507827626200",
375                "service-instance-id": "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5",
376                "service-instance-name": "Service_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
377               }
378              }, {
379               "extra-properties": {
380                "extra-property": [{
381                 "property-name": "model-ver.model-version-id",
382                 "property-value": "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"
383                }, {
384                 "property-name": "model-ver.model-name",
385                 "property-value": "generic-vnf"
386                }, {
387                 "property-name": "model.model-type",
388                 "property-value": "widget"
389                }, {
390                 "property-name": "model.model-invariant-id",
391                 "property-value": "acc6edd8-a8d4-4b93-afaa-0994068be14c"
392                }, {
393                 "property-name": "model-ver.model-version",
394                 "property-value": "1.0"
395                }]
396               },
397               "model-name": "generic-vnf",
398               "vf-module": {
399                "heat-stack-id": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/5845f37b-6cda-4e91-8ca3-f5572d226488",
400                "is-base-vf-module": true,
401                "model-invariant-id": "acc6edd8-a8d4-4b93-afaa-0994068be14c",
402                "model-version-id": "93a6166f-b3d5-4f06-b4ba-aed48d009ad9",
403                "orchestration-status": "active",
404                "resource-version": "1507826326804",
405                "vf-module-id": "b0eff878-e2e1-4947-9597-39afdd0f51dd",
406                "vf-module-name": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
407               }
408              }]
409             },
410             "model-name": "generic-vnf"
411            }, {
412             "extra-properties": {},
413             "inventory-response-items": {
414              "inventory-response-item": [{
415               "cloud-region": {
416                "cloud-owner": "Rackspace",
417                "cloud-region-id": "DFW",
418                "cloud-region-version": "v1",
419                "cloud-type": "SharedNode",
420                "cloud-zone": "CloudZone",
421                "owner-defined-type": "OwnerType",
422                "resource-version": "1507828410019",
423                "sriov-automation": false
424               },
425               "extra-properties": {}
426              }]
427             },
428             "tenant": {
429              "resource-version": "1507828410764",
430              "tenant-id": "1015548",
431              "tenant-name": "1015548"
432             }
433            }]
434           },
435           "vserver": {
436            "in-maint": false,
437            "is-closed-loop-disabled": false,
438            "prov-status": "ACTIVE",
439            "resource-version": "1507828410832",
440            "vserver-id": "70f081eb-2a87-4c81-9296-4b93d7d145c6",
441            "vserver-name": "vlb-lb-32c8",
442            "vserver-name2": "vlb-lb-32c8",
443            "vserver-selflink": "https://aai.api.simpledemo.openecomp.org:8443/aai/v11/nodes/vservers?vserver-name=vlb-lb-32c8"
444           }
445          }]
446         }
447
448
449     .. code-block:: bash
450        :caption: NamedQuery-error
451
452         // This is returned if you query the value "error"
453         {
454          "requestError": {
455           "serviceException": {
456            "messageId": "SVC3001",
457            "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
458            "variables": ["POST Search", "getNamedQueryResponse", "Node Not Found:No Node of type generic-vnf found for properties", "ERR.5.4.6114"]
459           }
460          }
461         }
462
463
464 **SO**
465
466     .. code-block:: bash
467        :caption: SO-response
468
469         {
470          "requestReferences": {
471           "instanceId": "ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff",
472           "requestId": "rq1234d1-5a33-ffdf-23ab-12abad84e331"
473          }
474         }
475
476
477 **vFC**
478
479     .. code-block:: bash
480        :caption: vFC-POST-response
481
482         {
483          "jobId": "1"
484         }
485
486
487     .. code-block:: bash
488        :caption: vFC-GET-response
489
490         {
491          "jobId": jobId, //The jod id that you query
492          "responseDescriptor": {
493           "progress": "40",
494           "status": "finished",
495           "statusDescription": "OMC VMs are decommissioned in VIM",
496           "errorCode": null,
497           "responseId": 101,
498           "responseHistoryList": [{
499            "progress": "40",
500            "status": "proccessing",
501            "statusDescription": "OMC VMs are decommissioned in VIM",
502            "errorCode": null,
503            "responseId": "1"
504           }, {
505            "progress": "41",
506            "status": "proccessing",
507            "statusDescription": "OMC VMs are decommissioned in VIM",
508            "errorCode": null,
509            "responseId": "2"
510           }]
511          }
512         }
513
514
515 **GUARD**
516
517     .. code-block:: bash
518        :caption: permit-response
519
520         {
521          "decision": "PERMIT",
522          "details": "Decision Permit. OK!"
523         }
524
525
526     .. code-block:: bash
527        :caption: deny-response
528
529         //This is returned if the closed loop name is denyGuard
530         {
531          "decision": "DENY",
532          "details": "Decision Deny. You asked for it"
533         }
534
535
536 End of Document
537
538 .. SSNote: Wiki page ref.  https://wiki.onap.org/pages/viewpage.action?pageId=16003633
539