Fix docs issues
[so.git] / docs / developer_info / BBUnderstanding.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2018 Huawei Technologies Co., Ltd.
4
5 Building Block Understanding
6 ============================
7
8 UNDERSTANDING BUILDING BLOCKS USING MACRO FLOW
9 ----------------------------------------------
10 There are basically 2 flows - macro , a la carte.
11
12 **In a la carte:**
13
14     We manually will initiate each step for a process.
15
16 **In macro:**
17
18   The whole flow happens at a single click like if we want to create a service.
19   The flow will itself look whether there are vnfs, pnfs or networks in the
20   service and it will be created and activated in the flow also.Thus these
21   independent tasks like if vnf is present, then assign create and activate vnf
22   are all taken up as individual building blocks and are only called on need
23   basis.
24   Each and every request will reach to the api handler first.
25
26 API HANDLER( ServiceInstances.java )
27 ------------------------------------
28
29
30
31 # 1. Rest call reaching SO Api handler with the input json
32
33     According to the below path it is mapped to the createServiceInstance
34     function in ServiceInstances file.
35
36     .. code-block:: bash
37
38         curl -v -H "Content-Type: application/json" -X POST --data @serviceinstance.json -u mso_admin:password1$ http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances.
39
40 # 2. Herein a unique requestid is generated corresponding to every request, and
41 is checked whether that particular requestid exists in request db (Happens in
42 createServiceInstance in ServiceInstances).
43
44     a. **http://request-db-adapter:8083/infraActiveRequests/requestid** (GET), which will return a 404 if not exists.
45
46     b. CreateInstance is set to the action variable. Here the request scope is
47        set to service from the inputjson - modelType.
48
49
50 # 3. Running local validations on input json.
51
52 # 4. create InfraActiveRequests, to store request details in request db adapter
53 and as a payload to bpmn.
54
55     a) A new InfraActiveRequests object is created. And all the necessary
56        information from the input is set to it.
57
58     b) Retrieving productFamilyName from the input json to put into requests db. **http://aai/servicedesigncreation/services/service/{productfamilyid}** (GET), which will return a 404 if not exists in aai. If service exists, then that service's serviceDescritiption is set as productfamilyName.
59
60     c) **http://aai/cloudinfrastructure/cloudregions/cloudregion/cloudowner/{lcpCloudRegionId}/tenants/tenant/{tenantId}** (GET), checks for whether the particular cloud configuration exists in aai, if not exists returns 404.  If we are able to get, then the tenant's name derived from aai is set as tenantName.
61
62     d) serviceInstanceName is derived from requestInfo.instanceName and is set.
63
64     e) Request json is also set as RequestBody of InfraActiveRequests.
65
66 # 5. Checks fro whether duplicate name exists.
67
68     a. version v[integer] is converted to the particular integer and stored.
69
70     b. Checks whether instance name already exists in with a POST request in **http://request-db-adapter:8083/infraActiveRequests/checkInstanceNameDuplicate**, with the data { instanceIdmap = null, instanceName = {instanceName} , instanceservice = service } . It checks for the current progress and if in progress it throws the particular status.
71
72 # 6. Gets the orchestration url from the recipe table.
73
74     a. Checks whether the service already exists in catalogdb **http://catalog-db-adapter:8082/service/{modelNameVersionId}** (GET).
75
76     b. Checks the service recipe table with the modelNameVersionId and the action to be performed **http://catalog-db-adapter:8082/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID={modelNameVersionId}&action=createInstance** . Returns a 404 if no recipe exists with the corresponding id.
77
78     c. As recipe corresponding to this doesn't exist, we try to get with a default value. This flow comes under generic resource flow so the default value is GR-API-DEFAULT. First we get service with this value **http://catalog-db-adapter:8082/service/search/findFirstByModelNameOrderByModelVersionDesc?modelName=GR-API-DEFAULT** (GET). It returns a service with modelUUID as d88da85c-d9e8-4f73-b837-3a72a431622b, and further can be used to get the recipe.
79
80     d. **http://catalog-db-adapter:8082/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622b&action=createInstance** (GET), gives a recipe which has a parameter "orchestrationUri" as "/mso/async/services/WorkflowActionBB".
81
82 # 7. Updates the infraActiveRequests with the current request.
83
84     a) **http://request-db-adapter:8083/infraActiveRequests/** (POST) with the data formed. And a 201 created response is received.
85
86 # 8. Call the bpmn with a post call on orchestrationUri. The data to bpmn is
87 prepared having parameters like
88
89     a) bpmnRequest - formed from input request.
90
91     b) vfModuleId, pnfCorrelationId, networkId, configurationId, vfModuleType,
92        serviceInstanceId , serviceType are updated if present in the input json
93        or else set to empty string.
94
95     c) apiVersion , requestId, aLaCarte = false (def), recipeTimeout = 180(def)
96        ,requestAction= createInstance are all updated accordingly.
97
98     d) requestUri - v7/serviceInstances ,which is formed from the request url.
99
100 # 9. A sync response is obtained on reaching bpmn like
101
102      {"requestReferences":{"requestId":"c45702f7-3f08-4081-bc98-2f9f18b81607","instanceId":"cadca18f-9bff-44be-8910-ad29d342e91f","requestSelfLink":**"http://159.138.57.166:30277/orchestrationRequests/v7/c45702f7-3f08-4081-bc98-2f9f18b81607"**}}.
103
104
105 # 10. Calls the WorkflowActionBB.bpmn
106
107 BPMN
108 ----
109
110 Hits WorkflowActionBB.bpmn
111 --------------------------
112
113 .. image:: ../images/workflow.png
114
115
116 # 10.1. RetrieveBBExecutionList - implemented in selectExecutionList in
117 WorkflowAction.java
118
119     a. resourcetype, resourceid are formed from matching the requestUri to a
120        regex pattern matcher
121
122      .. code-block:: bash
123
124         [pattern=[vV]\d+.*?(?:(?:/(?<type>vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups)(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?(?:/resume)?)] .
125
126     b. Checks whether there is a service subscription with service instance name as {instanceName} correspoding to the customer in aai
127
128         .. code-block:: bash
129
130             https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances?depth=2&resultIndex=0&resultSize=1&service-instance-name={instanceName}.
131
132         Returns 404 not found, if it doesnt exists then the id of that particular instance is taken and given as both the resourceid and serviceinstance id. If not present then a random value is generated, and is assigned same to both.
133
134     c. Checks whether there is a service of the particular serviceInstanceId exists in aai. **https://aai.onap:8443/aai/v19/nodes/service-instances/service-instance/{serviceInstanceId}** , returns not found if it doesnt exist. If service with corresponding instance name already exists , then flowsToExecute is got by quering the requestdbadapter with the earlier request id.  If not present, then only orchestrationflows are got, and later from that the flowsToExecute are found out.
135
136     d. Get the particular service from catalogdb . **http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}**  (GET). Be sure that the service with this particular modelNameVersionId exists in catalogdb, because based on the services (like whether pnf, or vnf, or networkcollection) present in that particular service, which all bbs to execute are decided.
137
138     e. This being a service, "service" is added to the resource list. And is checked upon for other resources like vnf and   network, eg:
139
140         **http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/vnfCustomizations** (GET)
141
142         **http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/collectionResourceCustomizations** (GET)
143
144         **http://so-catalog-db-adapter.onap:8082/service/{modelNameVersionId}/networkCustomizations** (GET)
145
146         And depending on the resources in the service, the resources found is updated like
147
148         Found :Service - 1    Vnf - 0    Pnf - 0    VfModule - 0    VolumeGroup - 0    Network - 0    VirtualLink - 0    NetworkCollection - 0    Configuration - 0    InstanceGroup - 0
149
150     f. Then the orchestration flows are get from the orchestration_flow_table depending on the cloudowner and request scope:
151
152         **http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/search/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType?action=createInstance&requestScope=Service&isALaCarte=false&cloudOwner={CloudOwner}&serviceType=%2A** (GET)
153
154         Here if present, then the orchestration flows are returned or else with default cloud owner, we try again
155
156         **http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/search/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType?action=createInstance&requestScope=Service&isALaCarte=false&cloudOwner=DEFAULT&serviceType=%2A** (GET)
157
158         Here in northBoundRequest is returned which has the parameter orchestrationFlowList, that contains the link that will return the orchestration flows.
159
160         "orchestrationFlowList" : { "href" : "**http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/101/orchestrationFlowList**"}
161
162         Now we do a get on the orchestration flow link to get the set of orchestration flows required
163
164         **http://so-catalog-db-adapter.onap:8082/northbound_request_ref_lookup/101/orchestrationFlowList**.
165
166         Here a set of 20 orchestration flows are returned under the action of Service-Macro-Create, each with a sequence no assigned sequentially in the given order
167
168         * AssignServiceInstanceBB,
169         * CreateNetworkCollectionBB,
170         * AssignNetworkBB,
171         * AssignVnfBB,
172         * AssignVolumeGroupBB,
173         * AssignVfModuleBB,
174         * ConfigAssignVnfBB,
175         * AssignPnfBB,
176         * WaitForPnfReadyBB,
177         * ActivatePnfBB,
178         * CreateNetworkBB,
179         * ActivateNetworkBB,
180         * CreateVolumeGroupBB,
181         * ActivateVolumeGroupBB,
182         * CreateVfModuleBB,
183         * ActivateVfModuleBB,
184         * ConfigDeployVnfBB,
185         * ActivateVnfBB,
186         * ActivateNetworkCollectionBB,
187         * ActivateServiceInstanceBB.
188
189
190         .. image:: ../images/flowchart.png
191
192
193     g. Flows to execute is determined by iterating through all the orchestartion flows and matching it with the found resources. It is merely a contains matching. In this particular as service was the only resource : List of BuildingBlocks to execute:AssignServiceInstanceBB, ActivateServiceInstanceBB.
194
195     h. processing data is added to the requestdbadapter. Here the data is post to the requestdb as two different building blocks **http://so-request-db-adapter.onap:8083/requestProcessingData**.
196
197     i. The already stored request details in request db is ammended like "lastModifiedBy" : "CamundaBPMN" , and status to in_progress with a put request.
198
199
200 # 10.2. sendSyncAck -  This was used to give an acknowledgement , with status
201 code as 200, and requestId and resourceId is sent as content.
202
203
204 # 10.3. Prevalidate the workflow
205
206
207 # 10.4. SelectBB - implemented in selectBBin WorkflowActionBBTasks
208
209     This is used to select the building block from the flows to execute
210     depending on the sequence order.
211
212      a. Depending on the current sequence , the building block is selected from
213         the flows to execute.
214
215      b. Execution variable, that is passed between the different building
216         blocks as the payload is amended as:
217         execution.setVariable("buildingBlock", buildingblockselected).
218
219      c. current sequence is incremented by 1, and updated in execution
220         variable.
221
222      d. Depending on whether currentSequence is greater than
223         flowsToExecute.size(), COMPLETED variable is either set to true
224         or false.
225
226 # 10.5. updateFlowStatistics - implemented in updateFlowStatistics in
227 WorkflowActionBBTasks
228
229     a. Depending on the current sequence no, the completed bb and next bb is
230        got from the flows to execute. And these are mentioned in a
231        statusMessage.
232
233     b. Percentage progress is got from the total no of bbs
234
235     c. These are ammended to the already present request in the request db
236
237
238 # 10.6. Execute BB - calls the ExecuteBuildingBlock.bpmn
239
240 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
241
242 Hits ExecuteBuildingBlock.bpmn
243 ------------------------------
244
245 .. image:: ../images/ExecuteBuildingBlock.png
246
247 # 10.6.1. BBInputSetup - implemented in execute in BBInputSetup
248
249     Here a generalbuildingblock is formed from executingbuildingblock after
250     certain updations and validations.
251
252      a. lookupKeyMap is formed from the input , and a map is formed with
253         serviceInstanceId, networkID, vnfID, pnfID, vfmoduleID, volumegroupID,
254         configurationID, instancegroupID as the keys.
255
256      b. Depending on whether a la carte or macro , different flows are called.
257         getGBBMacro is called in here.
258
259      c. In getGBBMacro , a valid customer is got with service subscription.
260         (getCustomerAndServiceSubscription)
261
262         First a customer is got by get request on **https://aai.onap:8443/aai/v19/business/customers/customer/{globalSubscriberId}**
263
264         After that ServiceSubscription is got by doing a get request
265
266         **https://aai.onap:8443/aai/v19/business/customers/customer/{globalSubscriberId}/service-subscriptions/service-subscription/service**
267
268         If, the above request doesnt give any , then ServiceSubscription is
269         fetched by first creating uri keys
270
271         **https://aai.onap:8443/aai/v19/nodes/service-instances/service-instance/{resourceId}?format=pathed**.
272
273         Then ServiceSubscription is got from the globalSubscriberId and the
274         uri keys
275
276         .. note:: a valid customer and a corresponding ServiceSubscription must
277             be present in the aai, for setting up the customer to gbuildingblock
278
279      d. project and owningEntity is updated from the input
280
281      e. service is got from the catalog db either by ModelVersionId or by ModelVersion and ModelInvariantId.
282
283      f. ServiceInstance is created from the above parameters, and this ServiceInstance is used in the preparation of general building block.
284
285      g. Depending on whether the current executing block name contains either of the network, or configuration, or network collection. A new instance of the corresponding type is created and is updated to the general building block (Happens in getGBBMacroNoUserParamsCreate)
286
287      h. This general building block is set to the gBuildingBlockExecution and gBBInput parameter of execution.
288
289
290 # 10.6.2. StatusPolicy - implemented in validateOrchestrationStatus in
291 OrchestrationStatusValidator. Input being gBuildingBlockExecution
292
293      a. orchestrationStatus is obtained after checking the resource type. We
294         had updated the orchestrationStatus in the above step when a new
295         service instance was created.
296
297      b. OrchestrationStatusStateTransitionDirective is got by doing a get call
298         to the catlog db with the url as
299         findOneByResourceTypeAndOrchestrationStatusAndTargetAction
300
301         **http://so-catalog-db-adapter.onap:8082/orchestrationStatusStateTransitionDirective/search/findOneByResourceTypeAndOrchestrationStatusAndTargetAction?resourceType=SERVICE&orchestrationStatus=PRECREATED&targetAction=ASSIGN**
302
303     c. orchestrationStatusValidationResult parameter is set to
304        executionvariable from the
305        OrchestrationStatusStateTransitionDirective.getFlowDirective()
306        "flowDirective" : "CONTINUE"
307
308 # 10.6.3. Prevalidate the gBuildingBlockExecution
309
310 # 10.6.4. BB To Execute: Depending on which building block is to be executed,
311 that particular bpmn is called .In this case, AssignServiceInstanceBB is called
312
313 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
314
315 .. topic:: Hits AssignServiceInstanceBB.bpmn
316
317     .. image:: ../images/AssignServiceInstanceBB.png
318
319 # 10.6.4.1. AAI create service subscription - implemented in
320 createServiceSubscription of createAAITasks
321
322     This method is used for creating and subscribing the service in A&AI
323
324      a. Customer is got from the general building block that was updated above
325
326      b. Here a serviceSubscriptionURI is formed by taking in the
327         globalSubscriberId and the serviceType
328
329      c. If a service subscription for the particular customer doesnt exist in
330         AAI, then a new subscription is created by taking in the
331         serviceSubscriptionURI
332
333     GET performed on uri:**https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service?
334     {"results":[{"service-subscription":1}]}**
335
336 # 10.6.4.2. AAI create service instance - implemented in createServiceInstance
337 of createAAITasks
338
339     This method is used for creating the service instance in A&AI
340
341      a. Customer is got from the general building block that was updated above
342
343      b. A serviceInstanceURI is formed by taking in the globalSubscriberId, the
344         serviceType and the service instance id
345
346      c. If the service instance in the particular path doesnt exist in AAI ,
347         then a new service instance is created by using the serviceInstanceURI
348
349      .. code-block:: bash
350
351             GET to:https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84?
352
353             response: {"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84","Node Not Found:No Node of type service-instance found at: business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84","ERR.5.4.6114"]}}}
354
355             Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84
356
357             with req body : {"service-instance-id":"2b955def-e536-40ee-84cb-3f06e3cc6d84","service-instance-name":"DEMO_123456","model-invariant-id":"944862ae-bb65-4429-8330-a6c9170d6672","model-version-id":"d88da85c-d9e8-4f73-b837-3a72a431622b","orchestration-status":"Inventoried"}
358
359 # 10.6.4.3. AAI create project - implemented in createProject of createAAITasks
360
361     This method is used for creation of the project A&AI.
362     Here too it checks whether a project with a  {projectName} exist in AAI .
363     If not it creates one, and connects it to the service instance identified
364     by the serviceInstanceId
365
366     .. code-block:: bash
367
368         Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/projects/project/name%20of%20proj/relationship-list/relationship
369
370         with req body: {"related-link":"/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84"}
371
372
373 # 10.6.4.4. AAI create owning entity -  implemented in createOwningEntity of
374 createAAITasks
375
376      a. OwningEntityId and OwningEntityName is extracted from the OwningEntity
377         given in the input json
378
379      b. If both of them are null, then an exception is raised.
380
381      c. If only OwningEntityId is null, then whether the OwningEntityName is
382         present in AAI is checked. If present then OwningEntityId is set by
383         quering the OwningEntity from AAI. And then connect it to the service
384         instance. If not present in the aai then a random id is generated and
385         assigned to  OwningEntityId. Then Owning entity is first created and
386         then connected to the service instance
387
388      d. Depending on whether the owning entity is already present or not,
389         either createOwningEntityandConnectServiceInstance is called, or
390         connectOwningEntityandServiceInstanceis called.
391
392         .. code-block:: bash
393
394             Sending HTTP PUT to:https://aai.onap:8443/aai/v19/business/owning-entities/owning-entity/owningEntityIdof%20owningEntity/relationship-list/relationship
395
396             req body: {"related-link":"/business/customers/customer/slice1/service-subscriptions/service-subscription/service/service-instances/service-instance/2b955def-e536-40ee-84cb-3f06e3cc6d84"}
397
398
399 # 10.6.4.5. SDNC Create Assign Request - implemented in assignServiceInstance
400 of SDNCAssignTasks
401
402      a. Here first the requestContext, serviceInstance, customer are obtained
403         from the general building block
404
405      b. Then a payload for the assignServiceInstance of the sdnc is formed by
406         passing in the above parameters to the assignServiceInstance in
407         sdncSIResources.
408
409      c. A new sdnc request is formed with the above thing as payload
410
411      d. This sdnc request is assigned to the SDNCRequest parameter of the
412         execution variable
413
414         .. code-block:: bash
415
416          {"input":{
417           "request-information" : {
418             "request-action" : "CreateServiceInstance",
419             "source" : "MSO",
420             "request-id" : "139636cd-4b69-4c3a-9e67-fed2c283baee"
421
422           },
423           "sdnc-request-header" : {
424
425             "svc-request-id" : "9bfe8cb0-bb8b-4dca-949d-2f2b51011b54",
426             "svc-action" : "assign"
427
428           },
429           "service-information" : {
430
431             "onap-model-information" : {
432               "model-name" : "GR-API-DEFAULT",
433               "model-version" : "1.0",
434               "model-uuid" : "d88da85c-d9e8-4f73-b837-3a72a431622b",
435               "model-invariant-uuid" : "944862ae-bb65-4429-8330-a6c9170d6672"
436
437             },
438             "subscription-service-type" : "service",
439             "service-id" : "2b955def-e536-40ee-84cb-3f06e3cc6d84",
440             "global-customer-id" : {global_customerid},
441             "service-instance-id" : "2b955def-e536-40ee-84cb-3f06e3cc6d84"
442
443           },
444           "service-request-input" : {
445
446             "service-input-parameters" : {
447               "param" : [ {
448                 "name" : "some name",
449                 "value" : "some value"
450
451               } ]
452
453             },
454             "service-instance-name" : {instance_name}
455           }
456          }}
457
458 # 10.6.4.6. It calls another bpmn file - SDNCHandler.bpmn
459
460      a. Setup callback variables -  Here mainly the correlator variable and the
461         sdnc timeout variable is set
462
463      b. callSDNC -  Here post call to sdnc client is done with the above
464         prepared payload. And then isSDNCCompleted is set to the execution
465         variable
466
467         Both the above tasks are implemented in SDNCRequestTasks.
468
469         **http://sdnc-oam.onap:8282/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/**
470
471 # 10.6.4.7. AAI Update (svc instance)- implemented in the
472 updateOrchestrationStatusAssignedService in AAIUpdateTasks
473
474      BPMN access method to update the status of Service to Assigned in AAI.
475      Here serviceInstance is obtained , then its orchestration status is
476      changed to assigned  and is updated in the AAI
477
478 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
479
480     Reaches back to ExecuteBuildingBlock.bpmn
481
482 # 10.6.5. Post validate the generic building block
483
484 # 10.6.6. Set Handling Code To Success - implemented in
485 setHandlingStatusSuccess in ExecuteBuildingBlockRainyDay handling code is set
486 to success for the execution variable
487
488 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
489
490     Reaches back to WorkflowActionBB.bpmn
491
492 # 10.7. postProcessingExecuteBB
493
494     If the building block excuted is ActivateVfModuleBB, then a
495     postProcessingExecuteBBActivateVfModule needs to be executed
496
497     Then again it is looped back to selectBB through a checkRetryStatus block.
498
499     This block comes into play only if the handlingCode is retry, and the retry
500     count is lesser than the maximum allowed no of retries, then the current
501     sequence is again reduced by 1 , so that the same block is executed again.
502     Request in the requestdb is updated with a setRetryStatusMessage,
503     keeping an eye on the no of retries executed.
504
505
506     And in this particular example ActivateServiceInstanceBB.
507     bpmn is called next in the sequence.
508
509     Here updateOrchestrationStatusActiveService is called, which is BPMN access
510     method to update status of Service to Active in AAI.
511     Here orchestrationStatus is set to active for the particular
512     service instance and is updated in the AAI .
513
514 # 10.8. updateRequestStatusToComplete is called if the "complete" flag is true
515
516      a. Here first the request is got from the requestDbclient **http://request-db-adapter:8083/infraActiveRequests/requestid**
517
518      b. Then a status message is formed as "Macro-" + resourceName + "-"
519         + action + " request was executed correctly."
520
521        This status message is updated in the request as well as is set to
522        finalStatusMessage of the execution variable
523
524      c. Other request parameters are updated
525
526           request.setEndTime(endTime);
527
528           request.setFlowStatus("Successfully completed all Building Blocks");
529
530           request.setProgress(Long.valueOf(100));
531
532           request.setRequestStatus("COMPLETE");
533
534           request.setLastModifiedBy("CamundaBPMN");
535
536      d. This new request parameters are updated by a put request to the
537         requestDbclient
538
539
540
541
542 Flow ends
543 ----------
544
545 If there are other resources present along with the service : Eg
546 :- Volumegroup.( These BBs wil be specifically called )
547
548 1) AssignVolumeGroupBB :
549
550      a. genericvnfid and volumegroupid is obtained from the execution block.
551      b. volumegroup orchestrationstatus is set to assigned
552      c. a volume group of the above details is created in aai
553      d. connect volumegroup to this genericvnf
554      e. cloud configuration is got,
555         and then the volumegroup is linked to tenant
556
557 2) createVolumeGroupBB :
558
559      a. get the vf details according to Vf module id from sdnc.
560      b. vfmodulequeriedfromsdnc is set to the executionvariable.
561      c. createVolumeGroupRequest is formed with getCloudRegion,
562         serviceinstance, genericVnf, volumegroup, sdncVfModuleQueryResponse.
563      d. calls vnfadapter, which in turn calls openstackadaptertask.
564      e. update heattask in the volumegroup and which is ammended in the aai.
565      f. orchestrationstatus for the volume group is set to created.
566
567 3) ActivateVolumeGroupBB :
568
569      orchestrationstatus for the volume group is ammended to active.
570
571 Rollback, Retry and abort
572 ------------------------------------
573
574 When exception is thrown then **Error handling**  event subprocess in BPMN
575 **ExecuteBuildingBlock** is invoked.
576
577     .. image:: ../images/handling_error.png
578
579     **QueryRainyDayTable task** main responsibility is to determine with
580     **rainy_day_handler_macro** table the right policy to apply in order to
581     recover from error.
582
583     For each BB a policy is defined in **rainy_day_handler_macro** table
584     (retry, rollback, abort ...)
585
586     **HandlingCode** parameter is populated with  BB **policy** value.
587
588
589
590 # 1. In case of retry handling code
591 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
592 Policy in **rainy_day_handler_macro** table for current BB failure is **Retry**
593
594 .. image:: ../images/retry_Bdd2.png
595
596 Once Error handling subprocess has set handlingCode to **retry** value,
597 the main process retries to execute previous failing BB (green arrow).
598
599 .. image:: ../images/retry.png
600
601 If a new failure occurred a **new retry** is performed
602 (green arrow in Error handling subprocess)
603
604 .. image:: ../images/retry3.png
605
606
607 Until **max retry count** is reached, this time **secondary policy**
608 will be queried.
609
610 .. image:: ../images/retry2.png
611
612 **HandlingCode** is now set with  **secondary policy** value from
613 rainy_day_handler_macro table (rollback, abort...)
614
615 .. image:: ../images/retry_Bdd.png
616
617
618 # 2. In case of rollback handling code
619 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
620
621 Policy in **rainy_day_handler_macro** table for current BB failure is set to
622 **Rollback** (or RollbackToXXX)
623
624
625     .. image:: ../images/rollback_Bdd.png
626
627 In case of Rollback the main process follows green arrows
628
629     .. image:: ../images/rollback.png
630
631     1) **HandlingCode** set previously in Error handling subprocess to Rollback
632        (or RollbackToXXX) drives to **RollBack Execution Path** in main process
633
634     2) **RollBack Execution Path** task has responsibility to prepare rollback
635        flow sequence.
636
637         BB FlowName are changed in the following way:
638
639         * AssignXXX => UnassignXXX
640         * CreateXXX => DeleteXXX
641         * ActivateXXX => DeactivateXXX
642         * AddXXX => DeleteXXX
643         * VNFSetXXX => VNFUnsetXXX
644         * VNFLockXXX => VNFUnLockXXX
645         * VNFStopXXX => VNFStartXXX
646         * VNFQuiesceXXX => VNFResumeXXX
647
648     3) and 4.   **Loop** on step **3** and step **4**,  BB are executed one after one in order to **rollback** previous flow execution.
649
650     5) RollBack completed.
651
652
653 # 3. In case of Abort handling code
654 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
655
656 Policy in **rainy_day_handler_macro** table for current BB failure is **Abort**
657
658 .. image:: ../images/abort.png
659
660
661
662 Suppress Rollback
663 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
664
665 Request can disable rollback with **suppressRollback** parameter
666
667 if **suppressRollback** is set to false value, **QueryRainyDayTable task**
668 will directly return abort without querying policy in table
669 **rainy_day_handler_macro**
670
671
672 .. code-block::
673
674     curl --location --request POST 'http://master2:30277/onap/so/infra/serviceInstantiation/v7/serviceInstances' \
675     --header 'Accept: application/json' \
676     --header 'Content-Type: application/json' \
677     --header 'Authorization: Basic abcdef' \
678     --header 'X-ONAP-PartnerName: NBI' \
679     --data-raw '{
680         "requestDetails": {
681             "subscriberInfo": {
682                 "globalSubscriberId": "ones"
683             },
684             "requestInfo": {
685                 "suppressRollback": false,
686                 "productFamilyId": "Useless_But_Mandatory",