59998576089de181c0fc2875cfdf63dc12bb838b
[so.git] /
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * OPENECOMP - MSO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.mso.bpmn.infrastructure.scripts\r
22 \r
23 import org.camunda.bpm.engine.delegate.BpmnError\r
24 import org.camunda.bpm.engine.runtime.Execution\r
25 import org.openecomp.mso.bpmn.common.scripts.AaiUtil\r
26 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
27 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils\r
28 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils\r
29 import org.openecomp.mso.bpmn.common.scripts.VfModule\r
30 import org.openecomp.mso.bpmn.common.scripts.VfModuleBase\r
31 import org.openecomp.mso.bpmn.core.WorkflowException\r
32 import org.openecomp.mso.bpmn.core.json.JsonUtils;\r
33 import org.openecomp.mso.rest.APIResponse\r
34 import org.springframework.web.util.UriUtils\r
35 \r
36 public class DoUpdateVfModule extends VfModuleBase {\r
37 \r
38         ExceptionUtil exceptionUtil = new ExceptionUtil()\r
39         JsonUtils jsonUtil = new JsonUtils()\r
40 \r
41         /**\r
42          * Initialize the flow's variables.\r
43          *\r
44          * @param execution The flow's execution instance.\r
45          */\r
46         public void initProcessVariables(Execution execution) {\r
47                 execution.setVariable('prefix', 'DOUPVfMod_')\r
48                 execution.setVariable('DOUPVfMod_requestInfo', null)\r
49                 execution.setVariable('DOUPVfMod_serviceInstanceId', null)\r
50                 execution.setVariable('DOUPVfMod_requestId', null)\r
51                 execution.setVariable('DOUPVfMod_vnfInputs', null)\r
52                 execution.setVariable('DOUPVfMod_vnfId', null)\r
53                 execution.setVariable('DOUPVfMod_vnfName', null)\r
54                 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)\r
55                 execution.setVariable('DOUPVfMod_vfModuleName', null)\r
56                 execution.setVariable('DOUPVfMod_vfModuleId', null)\r
57                 execution.setVariable('DOUPVfMod_vnfType', null)\r
58                 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)\r
59                 execution.setVariable('DOUPVfMod_vfModuleModelName', null)\r
60                 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)\r
61                 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")\r
62                 execution.setVariable('DOUPVfMod_serviceId', null)\r
63                 execution.setVariable('DOUPVfMod_aicCloudRegion', null)\r
64                 execution.setVariable('DOUPVfMod_tenantId', null)\r
65                 execution.setVariable('DOUPVfMod_volumeGroupId', null)\r
66                 execution.setVariable('DOUPVfMod_vfModule', null)\r
67                 execution.setVariable('DOUPVfMod_vnfParams', null)\r
68                 execution.setVariable("DOUPVfMod_baseVfModuleId", "")\r
69                 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")\r
70                 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)\r
71                 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)\r
72                 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)\r
73                 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)\r
74                 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)\r
75                 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)\r
76                 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)\r
77                 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)\r
78                 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)\r
79                 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)\r
80                 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)\r
81                 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)\r
82         }\r
83 \r
84         /**\r
85          * Check for missing elements in the received request.\r
86          *\r
87          * @param execution The flow's execution instance.\r
88          */\r
89         public void preProcessRequest(Execution execution) {\r
90                 def method = getClass().getSimpleName() + '.preProcessRequest(' +\r
91                         'execution=' + execution.getId() +\r
92                         ')'\r
93                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
94                 logDebug('Entered ' + method, isDebugLogEnabled)\r
95 \r
96                 try {\r
97                         initProcessVariables(execution)\r
98                         def xml = getVariable(execution, 'DoUpdateVfModuleRequest')\r
99                         utils.logAudit("DoUpdateVfModule request: " + xml)\r
100                         logDebug('Received request xml:\n' + xml, isDebugLogEnabled)\r
101                         \r
102                         if (xml == null || xml.isEmpty()) {\r
103                                 // Building Block-type request\r
104 \r
105                                 String cloudConfiguration = execution.getVariable("cloudConfiguration")\r
106                                 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")\r
107                                 \r
108                                 def serviceModelInfo = execution.getVariable("serviceModelInfo")\r
109                                 logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled)\r
110                                 def vnfModelInfo = execution.getVariable("vnfModelInfo")\r
111                                 \r
112 \r
113                                 //tenantId\r
114                                 def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")\r
115                                 execution.setVariable("DOUPVfMod_tenantId", tenantId)\r
116                                 \r
117                                 //volumeGroupId\r
118                                 def volumeGroupId = execution.getVariable("volumeGroupId")\r
119                                 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)\r
120                                 //volumeGroupName\r
121                                 def volumeGroupName = execution.getVariable("volumeGroupName")\r
122                                 execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName)\r
123                                 //cloudSiteId\r
124                                 def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")\r
125                                 execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId)\r
126                                 \r
127                                 logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled)\r
128                                 //vnfType\r
129                                 def vnfType = execution.getVariable("vnfType")\r
130                                 execution.setVariable("DOUPVfMod_vnfType", vnfType)\r
131                                 \r
132                                 logDebug("vnfType: " + vnfType, isDebugLogEnabled)\r
133                                 //vnfName\r
134                                 def vnfName = execution.getVariable("vnfName")\r
135                                 execution.setVariable("DOUPVfMod_vnfName", vnfName)\r
136                                 \r
137                                 logDebug("vnfName: " + vnfName, isDebugLogEnabled)\r
138                                 //vnfId\r
139                                 def vnfId = execution.getVariable("vnfId")\r
140                                 execution.setVariable("DOUPVfMod_vnfId", vnfId)\r
141                                 \r
142                                 logDebug("vnfId: " + vnfId, isDebugLogEnabled)\r
143                                 //vfModuleName\r
144                                 def vfModuleName = execution.getVariable("vfModuleName")\r
145                                 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)\r
146                                 \r
147                                 logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled)\r
148                                 //vfModuleModelName\r
149                                 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")\r
150                                 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)\r
151                                 \r
152                                 logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled)\r
153                                 //modelCustomizationUuid\r
154                                 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId")\r
155                                 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)\r
156                                 \r
157                                 logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled)\r
158                                 //vfModuleId\r
159                                 def vfModuleId = execution.getVariable("vfModuleId")\r
160                                 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)\r
161                                 logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled)\r
162                                 def requestId = execution.getVariable("requestId")\r
163                                 execution.setVariable("DOUPVfMod_requestId", requestId)\r
164                                 logDebug("requestId: " + requestId, isDebugLogEnabled)\r
165                                 // Set mso-request-id to request-id for VNF Adapter interface\r
166                                 execution.setVariable("mso-request-id", requestId)\r
167                                 //serviceId\r
168                                 def serviceId = execution.getVariable("serviceId")\r
169                                 execution.setVariable("DOUPVfMod_serviceId", serviceId)\r
170                                 logDebug("serviceId: " + serviceId, isDebugLogEnabled)\r
171                                 //serviceInstanceId\r
172                                 def serviceInstanceId = execution.getVariable("serviceInstanceId")\r
173                                 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)\r
174                                 \r
175                                 logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled)\r
176                                 //source - HARDCODED\r
177                                 def source = "VID"\r
178                                 execution.setVariable("DOUPVfMod_source", source)\r
179                                 \r
180                                 logDebug("source: " + source, isDebugLogEnabled)\r
181                                 //backoutOnFailure\r
182                                 def disableRollback = execution.getVariable("disableRollback")\r
183                                 def backoutOnFailure = true\r
184                                 if (disableRollback != null && disableRollback.equals("true")) {\r
185                                         backoutOnFailure = false\r
186                                 }\r
187                                 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)\r
188                                 logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled)\r
189                                 //isBaseVfModule\r
190                                 def isBaseVfModule = execution.getVariable("isBaseVfModule")\r
191                                 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)\r
192                                 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)\r
193                                 //asdcServiceModelVersion\r
194                                 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")\r
195                                 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)\r
196                                 logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled)\r
197                                 //personaModelId\r
198                                 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId"))\r
199                                 //personaModelVersion\r
200                                 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))\r
201                                 //Get or Generate UUID\r
202                                 String uuid = execution.getVariable("DOUPVfMod_uuid")\r
203                                 if(uuid == null){\r
204                                         uuid = UUID.randomUUID()\r
205                                         logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled)\r
206                                 }else{\r
207                                         logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled)\r
208                                 }\r
209                                 //isVidRequest\r
210                                 String isVidRequest = execution.getVariable("isVidRequest")\r
211                                 // default to true\r
212                                 if (isVidRequest == null || isVidRequest.isEmpty()) {\r
213                                         execution.setVariable("isVidRequest", "true")\r
214                                 }\r
215                                 //globalSubscriberId\r
216                                 String globalSubscriberId = execution.getVariable("globalSubscriberId")\r
217                                 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)\r
218                                 logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)\r
219                                 //vnfQueryPath\r
220                                 String vnfQueryPath = execution.getVariable("vnfQueryPath")\r
221                                 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)\r
222                                 logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)\r
223 \r
224                                 String vnfParamsChildNodes = execution.getVariable("vfModuleInputParams")\r
225                                 execution.setVariable('DOUPVfMod_vnfParams', vnfParamsChildNodes)\r
226                         }\r
227                         else {\r
228 \r
229                                 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')\r
230                                 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)\r
231                                 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))\r
232                         def serviceInstanceId = execution.getVariable('mso-service-instance-id')\r
233                                 if (serviceInstanceId == null) {\r
234                                         serviceInstanceId = ''\r
235                                 }\r
236                                 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)\r
237         \r
238                                 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')\r
239                                 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)\r
240                                 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))\r
241                                 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))\r
242                                 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))\r
243                                 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))\r
244                                 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))\r
245                                 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))\r
246                                 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))\r
247                                 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))\r
248                                 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))\r
249                                 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))\r
250                                 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))\r
251                                 //isBaseVfModule\r
252                                 def isBaseVfModule = "false"\r
253                                 if (utils.nodeExists(xml, "is-base-vf-module")) {\r
254                                         isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")\r
255                                         execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)\r
256                                 }\r
257                                 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)\r
258         \r
259                                 NetworkUtils networkUtils = new NetworkUtils()\r
260                                 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)\r
261                                 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)\r
262         \r
263                                 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')\r
264                                 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)\r
265         \r
266                                 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))\r
267                         }\r
268 \r
269                         def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
270                         if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {\r
271                                 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'\r
272                                 logError(msg)\r
273                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
274                         }\r
275 \r
276                         logDebug('Exited ' + method, isDebugLogEnabled)\r
277                 } catch (BpmnError e) {\r
278                         throw e;\r
279                 } catch (Exception e) {\r
280                         logError('Caught exception in ' + method, e)\r
281                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())\r
282                 }\r
283         }\r
284 \r
285         /**\r
286          * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow.  This will\r
287          * set the orchestration-status to 'pending-update'.\r
288          *\r
289          * @param execution The flow's execution instance.\r
290          */\r
291         public void prepPrepareUpdateAAIVfModule(Execution execution) {\r
292                 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +\r
293                         'execution=' + execution.getId() +\r
294                         ')'\r
295                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
296                 logDebug('Entered ' + method, isDebugLogEnabled)\r
297 \r
298                 try {\r
299                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
300                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
301                         def orchestrationStatus = 'pending-update'\r
302 \r
303                         String prepareUpdateAAIVfModuleRequest = """\r
304                                 <PrepareUpdateAAIVfModuleRequest>\r
305                                         <vnf-id>${vnfId}</vnf-id>\r
306                                         <vf-module-id>${vfModuleId}</vf-module-id>\r
307                                         <orchestration-status>${orchestrationStatus}</orchestration-status>\r
308                                 </PrepareUpdateAAIVfModuleRequest>\r
309                         """\r
310                         prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)\r
311                         execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)\r
312                         utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)\r
313                         logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)\r
314 \r
315                         logDebug('Exited ' + method, isDebugLogEnabled)\r
316                 } catch (BpmnError e) {\r
317                         throw e;\r
318                 } catch (Exception e) {\r
319                         logError('Caught exception in ' + method, e)\r
320                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())\r
321                 }\r
322         }\r
323 \r
324         /**\r
325          * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.  Currently,\r
326          * there is really nothing to do, so we just log that we're passing through.\r
327          *\r
328          * @param execution The flow's execution instance.\r
329          */\r
330         public void prepConfirmVolumeGroupTenant(Execution execution) {\r
331                 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +\r
332                         'execution=' + execution.getId() +\r
333                         ')'\r
334                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
335                 logDebug('Entered ' + method, isDebugLogEnabled)\r
336 \r
337                 try {\r
338                         // Nothing to do - just log that we're passing through here\r
339 \r
340                         logDebug('Exited ' + method, isDebugLogEnabled)\r
341                 } catch (BpmnError e) {\r
342                         throw e;\r
343                 } catch (Exception e) {\r
344                         logError('Caught exception in ' + method, e)\r
345                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage())\r
346                 }\r
347         }\r
348 \r
349         /**\r
350          * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
351          * a VNF topology 'changeassign' operation.\r
352          *\r
353          * @param execution The flow's execution instance.\r
354          */\r
355         public void prepSDNCTopologyChg(Execution execution) {\r
356                 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +\r
357                         'execution=' + execution.getId() +\r
358                         ')'\r
359                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
360                 logDebug('Entered ' + method, isDebugLogEnabled)\r
361 \r
362                 try {\r
363                         def requestId = execution.getVariable('DOUPVfMod_requestId')\r
364                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
365                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
366                         def serviceId = execution.getVariable('DOUPVfMod_serviceId')\r
367                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
368                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
369                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
370                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
371                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
372                         def vfModuleName = vfModule.getElementText('vf-module-name')\r
373                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
374                         def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
375 \r
376                         // Retrieve vnf name from AAI response\r
377                         def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')\r
378                         execution.setVariable('DOUPVfMod_vnfName', vnfName)\r
379 \r
380                         def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
381                         def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)\r
382 \r
383                         String sdncTopologyRequest = """\r
384                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
385                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
386                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
387                                         <sdncadapter:RequestHeader>\r
388                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
389                                                 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>\r
390                                                 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>\r
391                                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>\r
392                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
393                                         </sdncadapter:RequestHeader>\r
394                                         <sdncadapterworkflow:SDNCRequestData>\r
395                                               <request-information>\r
396                                                  <request-id>${requestId}</request-id>\r
397                                                  <request-action>ChangeVNFActivateRequest</request-action>\r
398                                                  <source>PORTAL</source>\r
399                                                  <notification-url/>\r
400                                                  <order-number/>\r
401                                                  <order-version/>\r
402                                               </request-information>\r
403                                               <service-information>\r
404                                                  <service-type>${serviceId}</service-type>\r
405                                                  <service-instance-id>${vnfId}</service-instance-id>\r
406                                                  <subscriber-name>dontcare</subscriber-name>\r
407                                               </service-information>\r
408                                               <vnf-request-information>\r
409                                                  <vnf-id>${vfModuleId}</vnf-id>\r
410                                                  <vnf-type>${vfModuleModelName}</vnf-type>\r
411                                                  <vnf-name>${vfModuleName}</vnf-name>\r
412                                                  <generic-vnf-id>${vnfId}</generic-vnf-id>\r
413                                                  <generic-vnf-name>${vnfName}</generic-vnf-name>\r
414                                                          <generic-vnf-type>${vnfType}</generic-vnf-type>\r
415                                                  <tenant>${tenantId}</tenant>\r
416                                                  <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>\r
417                                                  ${vnfNetworks}\r
418                                               </vnf-request-information>\r
419                                         </sdncadapterworkflow:SDNCRequestData>\r
420                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
421                         """\r
422                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
423                         execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)\r
424                         utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)\r
425                         logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
426 \r
427                         logDebug('Exited ' + method, isDebugLogEnabled)\r
428                 } catch (BpmnError e) {\r
429                         throw e;\r
430                 } catch (Exception e) {\r
431                         logError('Caught exception in ' + method, e)\r
432                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())\r
433                 }\r
434         }\r
435 \r
436         /**\r
437          * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
438          * a VNF topology 'query' operation.\r
439          *\r
440          * @param execution The flow's execution instance.\r
441          */\r
442         public void prepSDNCTopologyQuery(Execution execution) {\r
443                 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +\r
444                         'execution=' + execution.getId() +\r
445                         ')'\r
446                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
447                 logDebug('Entered ' + method, isDebugLogEnabled)\r
448 \r
449                 try {\r
450                         def requestId = execution.getVariable('DOUPVfMod_requestId')\r
451                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
452                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
453                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
454 \r
455                         def svcInstId = ""\r
456                         if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {\r
457                                 svcInstId = vfModuleId\r
458                         }\r
459                         else {\r
460                                 svcInstId = serviceInstanceId\r
461                         }\r
462 \r
463                         //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE\r
464                         sleep(5000)\r
465 \r
466                         String sdncTopologyRequest = """\r
467                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
468                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
469                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
470                                         <sdncadapter:RequestHeader>\r
471                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
472                                                 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>\r
473                                                 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>\r
474                                                 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>\r
475                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
476                                                 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>\r
477                                         </sdncadapter:RequestHeader>\r
478                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
479                         """\r
480                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
481                         execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)\r
482                         utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)\r
483                         logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
484 \r
485                         logDebug('Exited ' + method, isDebugLogEnabled)\r
486                 } catch (BpmnError e) {\r
487                         throw e;\r
488                 } catch (Exception e) {\r
489                         logError('Caught exception in ' + method, e)\r
490                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())\r
491                 }\r
492         }\r
493 \r
494         /**\r
495          * Prepare a Request for invoking the VnfAdapterRest subflow.\r
496          *\r
497          * @param execution The flow's execution instance.\r
498          */\r
499         public void prepVnfAdapterRest(Execution execution) {\r
500                 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +\r
501                         'execution=' + execution.getId() +\r
502                         ')'\r
503                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
504                 logDebug('Entered ' + method, isDebugLogEnabled)\r
505 \r
506                 try {\r
507                         def requestId = execution.getVariable('DOUPVfMod_requestId')\r
508                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
509                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
510                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
511                         def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')\r
512                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
513                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
514                         def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')\r
515                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
516                         def heatStackId = vfModule.getElementText('heat-stack-id')\r
517                         def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
518                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
519                         def vnfName = execution.getVariable('DOUPVfMod_vnfName')\r
520                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
521                         def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")\r
522                         def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")\r
523                         def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')\r
524                         def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')\r
525                         def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")\r
526 \r
527                         def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
528                         def vfModuleParamsEntries = transformParamsToEntries(vnfParamsXml)\r
529 \r
530                         def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()\r
531                         def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)\r
532                         def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")\r
533                         if ('true'.equals(useQualifiedHostName)) {\r
534                                         notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)\r
535                         }\r
536 \r
537                         String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')\r
538 \r
539                         String vfModuleParams = buildVfModuleParams(vfModuleParamsEntries, sdncGetResponse, vnfId, vnfName,\r
540                                         vfModuleId, vfModuleName, null)\r
541 \r
542 \r
543                         String vnfAdapterRestRequest = """\r
544                                 <updateVfModuleRequest>\r
545                                         <cloudSiteId>${cloudId}</cloudSiteId>\r
546                                         <tenantId>${tenantId}</tenantId>\r
547                                         <vnfId>${vnfId}</vnfId>\r
548                                         <vfModuleId>${vfModuleId}</vfModuleId>\r
549                                         <vfModuleStackId>${heatStackId}</vfModuleStackId>\r
550                                         <vnfType>${vnfType}</vnfType>\r
551                                         <vnfVersion>${asdcServiceModelVersion}</vnfVersion>\r
552                                         <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>\r
553                                         <vfModuleType>${vfModuleModelName}</vfModuleType>\r
554                                         <volumeGroupId>${volumeGroupId}</volumeGroupId>\r
555                                         <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>\r
556                                 <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>\r
557                                         <skipAAI>true</skipAAI>\r
558                                         <backout>${backoutOnFailure}</backout>\r
559                                     <failIfExists>false</failIfExists>\r
560                                         <vfModuleParams>\r
561                                                 ${vfModuleParams}\r
562                                     </vfModuleParams>\r
563                                     <msoRequest>\r
564                                         <requestId>${requestId}</requestId>\r
565                                         <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
566                                     </msoRequest>\r
567                                     <messageId>${messageId}</messageId>\r
568                                     <notificationUrl>${notificationUrl}</notificationUrl>\r
569                                 </updateVfModuleRequest>\r
570                         """\r
571                         vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)\r
572                         execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)\r
573                         utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)\r
574                         logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)\r
575 \r
576                         logDebug('Exited ' + method, isDebugLogEnabled)\r
577                 } catch (BpmnError e) {\r
578                         throw e;\r
579                 } catch (Exception e) {\r
580                         logError('Caught exception in ' + method, e)\r
581                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())\r
582                 }\r
583         }\r
584 \r
585         /**\r
586          * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.\r
587          *\r
588          * @param execution The flow's execution instance.\r
589          */\r
590         public void prepUpdateAAIGenericVnf(Execution execution) {\r
591                 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +\r
592                         'execution=' + execution.getId() +\r
593                         ')'\r
594                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
595                 logDebug('Entered ' + method, isDebugLogEnabled)\r
596 \r
597                 try {\r
598                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
599                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
600 \r
601                         def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id')\r
602                         def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version')\r
603                         if ((personaModelId == null) || (personaModelVersion == null)) {\r
604                                 logDebug('Skipping update for Generic VNF ' + vnfId +\r
605                                         ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled)\r
606                                 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)\r
607                         } else {\r
608                                 def personaModelIdElement = '<persona-model-id>' + personaModelId + '</persona-model-id>'\r
609                                 def personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'\r
610 \r
611                                 String updateAAIGenericVnfRequest = """\r
612                                         <UpdateAAIGenericVnfRequest>\r
613                                                 <vnf-id>${vnfId}</vnf-id>\r
614                                                 ${personaModelIdElement}\r
615                                                 ${personaModelVersionElement}\r
616                                         </UpdateAAIGenericVnfRequest>\r
617                                 """\r
618                                 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)\r
619                                 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)\r
620                                 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)\r
621                                 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)\r
622                         }\r
623 \r
624                         logDebug('Exited ' + method, isDebugLogEnabled)\r
625                 } catch (BpmnError e) {\r
626                         throw e;\r
627                 } catch (Exception e) {\r
628                         logError('Caught exception in ' + method, e)\r
629                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())\r
630                 }\r
631         }\r
632 \r
633         /**\r
634          * Prepare a Request for invoking the UpdateAAIVfModule subflow.\r
635          *\r
636          * @param execution The flow's execution instance.\r
637          */\r
638         public void prepUpdateAAIVfModule(Execution execution) {\r
639                 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +\r
640                         'execution=' + execution.getId() +\r
641                         ')'\r
642                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
643                 logDebug('Entered ' + method, isDebugLogEnabled)\r
644 \r
645                 try {\r
646                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
647                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
648                         def orchestrationStatus = 'updated'\r
649                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
650 \r
651                         def volumeGroupIdElement = ''\r
652                         def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')\r
653                         if (volumeGroupId != null) {\r
654                                 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'\r
655                         }\r
656                         def personaModelIdElement = ''\r
657                         def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')\r
658                         if (personaModelId != null) {\r
659                                 personaModelIdElement = '<persona-model-id>' + personaModelId + '</persona-model-id>'\r
660                         }\r
661                         def personaModelVersionElement = ''\r
662                         def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')\r
663                         if (personaModelVersion != null) {\r
664                                 personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'\r
665                         }\r
666                         def contrailServiceInstanceFqdnElement = ''\r
667                         def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')\r
668                         if (contrailServiceInstanceFqdn != null) {\r
669                                 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'\r
670                         }\r
671                         def personaModelCustomizationIdElement = ''\r
672                         def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')\r
673                         if (modelCustomizationId != null) {\r
674                                 personaModelCustomizationIdElement = '<persona-model-customization-id>' + modelCustomizationId + '</persona-model-customization-id>'\r
675                         }\r
676 \r
677                         String updateAAIVfModuleRequest = """\r
678                                 <UpdateAAIVfModuleRequest>\r
679                                         <vnf-id>${vnfId}</vnf-id>\r
680                                         <vf-module-id>${vfModuleId}</vf-module-id>\r
681                                         <orchestration-status>${orchestrationStatus}</orchestration-status>\r
682                                         ${volumeGroupIdElement}\r
683                                         ${personaModelIdElement}\r
684                                         ${personaModelVersionElement}\r
685                                         ${contrailServiceInstanceFqdnElement}\r
686                                         ${personaModelCustomizationIdElement}\r
687                                 </UpdateAAIVfModuleRequest>\r
688                         """\r
689                         updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)\r
690                         execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)\r
691                         utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)\r
692                         logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)\r
693 \r
694                         logDebug('Exited ' + method, isDebugLogEnabled)\r
695                 } catch (BpmnError e) {\r
696                         throw e;\r
697                 } catch (Exception e) {\r
698                         logError('Caught exception in ' + method, e)\r
699                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())\r
700                 }\r
701         }\r
702 \r
703         /**\r
704          * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
705          * a VNF topology 'activate' operation.\r
706          *\r
707          * @param execution The flow's execution instance.\r
708          */\r
709         public void prepSDNCTopologyAct(Execution execution) {\r
710                 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +\r
711                         'execution=' + execution.getId() +\r
712                         ')'\r
713                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
714                 logDebug('Entered ' + method, isDebugLogEnabled)\r
715 \r
716                 try {\r
717                         def requestId = execution.getVariable('DOUPVfMod_requestId')\r
718                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
719                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
720                         def serviceId = execution.getVariable('DOUPVfMod_serviceId')\r
721                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
722                         def vnfName = execution.getVariable('DOUPVfMod_vnfName')\r
723                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
724                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
725                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
726                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
727                         def vfModuleName = vfModule.getElementText('vf-module-name')\r
728                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
729                         def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
730 \r
731                         def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
732                         def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)\r
733 \r
734                         String sdncTopologyRequest = """\r
735                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
736                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
737                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
738                                         <sdncadapter:RequestHeader>\r
739                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
740                                                 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>\r
741                                                 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>\r
742                                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>\r
743                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
744                                         </sdncadapter:RequestHeader>\r
745                                         <sdncadapterworkflow:SDNCRequestData>\r
746                                               <request-information>\r
747                                                  <request-id>${requestId}</request-id>\r
748                                                  <request-action>ChangeVNFActivateRequest</request-action>\r
749                                                  <source>PORTAL</source>\r
750                                                  <notification-url/>\r
751                                                  <order-number/>\r
752                                                  <order-version/>\r
753                                               </request-information>\r
754                                               <service-information>\r
755                                                  <service-type>${serviceId}</service-type>\r
756                                                  <service-instance-id>${vnfId}</service-instance-id>\r
757                                                  <subscriber-name>dontcare</subscriber-name>\r
758                                               </service-information>\r
759                                               <vnf-request-information>\r
760                                                  <vnf-id>${vfModuleId}</vnf-id>\r
761                                                  <vnf-type>${vfModuleModelName}</vnf-type>\r
762                                                  <vnf-name>${vfModuleName}</vnf-name>\r
763                                                  <generic-vnf-id>${vnfId}</generic-vnf-id>\r
764                                                  <generic-vnf-name>${vnfName}</generic-vnf-name>\r
765                                                          <generic-vnf-type>${vnfType}</generic-vnf-type>\r
766                                                  <tenant>${tenantId}</tenant>\r
767                                                  <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>\r
768                                               </vnf-request-information>\r
769                                         </sdncadapterworkflow:SDNCRequestData>\r
770                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
771                         """\r
772                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
773                         execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)\r
774                         utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)\r
775                         logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
776 \r
777 \r
778                         logDebug('Exited ' + method, isDebugLogEnabled)\r
779                 } catch (BpmnError e) {\r
780                         throw e;\r
781                 } catch (Exception e) {\r
782                         logError('Caught exception in ' + method, e)\r
783                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())\r
784                 }\r
785         }\r
786 \r
787         /**\r
788          * Log a WorkflowException that has been created.\r
789          *\r
790          * @param execution The flow's execution instance.\r
791          */\r
792         public void handleWorkflowException(Execution execution) {\r
793                 def method = getClass().getSimpleName() + '.handleWorkflowException(' +\r
794                         'execution=' + execution.getId() +\r
795                         ')'\r
796                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
797                 logDebug('Entered ' + method, isDebugLogEnabled)\r
798 \r
799                 try {\r
800                         def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')\r
801                         logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage())\r
802 \r
803                         logDebug('Exited ' + method, isDebugLogEnabled)\r
804                 } catch (BpmnError e) {\r
805                         throw e;\r
806                 } catch (Exception e) {\r
807                         logError('Caught exception in ' + method, e)\r
808                         exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())\r
809                 }\r
810         }\r
811 \r
812         public void validateSDNCResponse(Execution execution, String response, String method){\r
813                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")\r
814                 def prefix = execution.getVariable("prefix")\r
815 \r
816                 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)\r
817 \r
818                 WorkflowException workflowException = execution.getVariable("WorkflowException")\r
819                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")\r
820 \r
821                 utils.logAudit("workflowException: " + workflowException)\r
822 \r
823                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)\r
824                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)\r
825 \r
826                 utils.logAudit("SDNCResponse: " + response)\r
827 \r
828                 String sdncResponse = response\r
829                 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){\r
830                         logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse, isDebugLogEnabled)\r
831                 }else{\r
832                         logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)\r
833                         throw new BpmnError("MSOWorkflowException")\r
834                 }\r
835                 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)\r
836         }\r
837 \r
838         /**\r
839          * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.\r
840          * A 200 response is expected with the VNF info in the response body. Will find out the base module info.\r
841          *\r
842          * @param execution The flow's execution instance.\r
843          */\r
844         public void queryAAIVfModule(Execution execution) {\r
845                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")\r
846                 def method = getClass().getSimpleName() + '.getVfModule(' +\r
847                         'execution=' + execution.getId() +\r
848                         ')'\r
849                 logDebug('Entered ' + method, isDebugLogEnabled)\r
850 \r
851                 try {\r
852                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
853                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
854 \r
855                         AaiUtil aaiUriUtil = new AaiUtil(this)\r
856                         String  aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)\r
857                         logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)\r
858 \r
859                         String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"\r
860                         utils.logAudit("AAI endPoint: " + endPoint)\r
861 \r
862                         try {\r
863                                 def aaiRequestId = UUID.randomUUID().toString()\r
864                                 logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)\r
865                                 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)\r
866                                 utils.logAudit("createVfModule - invoking httpGet() to AAI")\r
867 \r
868                                 def responseData = response.getResponseBodyAsString()\r
869                                 if (responseData != null) {\r
870                                         logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)\r
871 \r
872                                 }\r
873 \r
874                                 utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)\r
875                                 utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())\r
876 \r
877                                 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())\r
878                                 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)\r
879                                 logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)\r
880                                 logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)\r
881                                 if (response.getStatusCode() == 200) {\r
882                                         // Parse the VNF record from A&AI to find base module info\r
883                                         logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)\r
884                                         if (responseData != null) {\r
885                                                 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")\r
886                                                 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)\r
887                                                 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}\r
888                                                 int vfModulesSize = 0\r
889                                                 for (i in 0..vfModules.size()-1) {\r
890                                                         def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])\r
891                                                         def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")\r
892 \r
893                                                         if (isBaseVfModule == "true") {\r
894                                                             String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")\r
895                                                             execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)\r
896                                                             logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled)\r
897                                                             String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id")\r
898                                                             execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)\r
899                                                             logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled)\r
900                                                         }\r
901                                                 }\r
902                                         }\r
903                                 }\r
904                         } catch (Exception ex) {\r
905                                 ex.printStackTrace()\r
906                                 logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)\r
907                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())\r
908                         }\r
909                         logDebug('Exited ' + method, isDebugLogEnabled)\r
910                 } catch (BpmnError e) {\r
911                         throw e;\r
912                 } catch (Exception e) {\r
913                         logError('Caught exception in ' + method, e)\r
914                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())\r
915                 }\r
916         }\r
917 \r
918 \r
919 }\r