aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
blob: af1161b6565889a70ce624be77462026e4703773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
/*-
 * ============LICENSE_START=======================================================
 * OPENECOMP - MSO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.mso.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
import org.openecomp.mso.bpmn.common.scripts.AaiUtil
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.rest.APIResponse
import org.springframework.web.util.UriUtils



public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{

	def Prefix="DCVFMR_"
	ExceptionUtil exceptionUtil = new ExceptionUtil()

	public void initProcessVariables(Execution execution) {
		execution.setVariable("prefix",Prefix)
	}

	// parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids
	// and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest
	public void preProcessRequest(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")

		initProcessVariables(execution)

		def rollbackData = execution.getVariable("RollbackData")
		String vnfId = rollbackData.get("VFMODULE", "vnfid")
		execution.setVariable("DCVFMR_vnfId", vnfId)
		String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid")
		execution.setVariable("DCVFMR_vfModuleId", vfModuleId)
		String source = rollbackData.get("VFMODULE", "source")
		execution.setVariable("DCVFMR_source", source)
		String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId")
		execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId)
		String serviceId = rollbackData.get("VFMODULE", "service-id")
		execution.setVariable("DCVFMR_serviceId", serviceId)
		String vnfType = rollbackData.get("VFMODULE", "vnftype")
		execution.setVariable("DCVFMR_vnfType", vnfType)
		String vnfName = rollbackData.get("VFMODULE", "vnfname")
		execution.setVariable("DCVFMR_vnfName", vnfName)
		String tenantId = rollbackData.get("VFMODULE", "tenantid")
		execution.setVariable("DCVFMR_tenantId", tenantId)
		String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename")
		execution.setVariable("DCVFMR_vfModuleName", vfModuleName)
		String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname")
		execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName)
		String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion")
		execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId)
		String heatStackId = rollbackData.get("VFMODULE", "heatstackid")
		execution.setVariable("DCVFMR_heatStackId", heatStackId)
		String requestId = rollbackData.get("VFMODULE", "attmsorequestid")
		execution.setVariable("DCVFMR_requestId", requestId)
		List createdNetworkPolicyFqdnList = []
		int i = 0
		while (i < 100) {
			String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i)
			if (fqdn == null) {
				break
			}
			createdNetworkPolicyFqdnList.add(fqdn)
			logDebug("got fqdn # " + i + ": " + fqdn, isDebugEnabled)
			i = i + 1

		}

		execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList)
		String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address")
		execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address)
		String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address")
		execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address)
		//String serviceInstanceId = rollbackData.get("VFMODULE", "attmsoserviceinstanceid")
		//execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId)
		execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule"))
		execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule"))
		execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate"))
		execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign"))
		execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate"))
		execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule"))
		execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI"))
		execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI"))

		// formulate the request for PrepareUpdateAAIVfModule
		String request = """<PrepareUpdateAAIVfModuleRequest>
								<vnf-id>${vnfId}</vnf-id>
								<vf-module-id>${vfModuleId}</vf-module-id>
								<orchestration-status>pending-delete</orchestration-status>
							</PrepareUpdateAAIVfModuleRequest>""" as String
		utils.log("DEBUG", "PrepareUpdateAAIVfModuleRequest :" + request, isDebugEnabled)
		utils.logAudit("DoCreateVfModuleRollback PrepareUpdateAAIVfModule Request: " + request)
		execution.setVariable("PrepareUpdateAAIVfModuleRequest", request)
	}

	// build a SDNC vnf-topology-operation request for the specified action
	// (note: the action passed is expected to be 'changedelete' or 'delete')
	public void prepSDNCAdapterRequest(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")

		def callbackUrl = execution.getVariable("URN_mso_workflow_sdncadapter_callback")

		String source = execution.getVariable("DCVFMR_source")
		String serviceId = execution.getVariable("DCVFMR_serviceId")
		String vnfId = execution.getVariable("DCVFMR_vnfId")
		String vnfType = execution.getVariable("DCVFMR_vnfType")
		String vnfName = execution.getVariable("DCVFMR_vnfName")
		String tenantId = execution.getVariable("DCVFMR_tenantId")
		String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
		String vfModuleName = execution.getVariable("DCVFMR_vfModuleName")
		String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName")
		String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId")
		String requestId = execution.getVariable("DCVFMR_requestId")

		String serviceInstanceIdToSdnc = ""
		if (srvInstId != null && !srvInstId.isEmpty()) {
			serviceInstanceIdToSdnc = srvInstId
		} else {
		    serviceInstanceIdToSdnc = vfModuleId
		}

		def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate")
		def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign")

		def action = ""
		def requestAction = ""

		if (doSDNCActivateRollback.equals("true")) {
			action = "delete"
			requestAction = "DisconnectVNFRequest"
		}
		else if (doSDNCAssignRollback.equals("true")) {
			action = "rollback"
			requestAction = "VNFActivateRequest"
		}
		else
			return


		String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
													xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
													xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
						      <sdncadapter:RequestHeader>
						         <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
						         <sdncadapter:SvcInstanceId>${vfModuleId}</sdncadapter:SvcInstanceId>
						         <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
						         <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
						         <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
						      </sdncadapter:RequestHeader>
						      <sdncadapterworkflow:SDNCRequestData>
						         <request-information>
						            <request-id>${requestId}</request-id>
						            <request-action>${requestAction}</request-action>
						            <source>${source}</source>
						            <notification-url/>
						            <order-number/>
						            <order-version/>
						         </request-information>
						         <service-information>
						            <service-id>${serviceId}</service-id>
									<service-type>${serviceId}</service-type>
						            <service-instance-id>${serviceInstanceIdToSdnc}</service-instance-id>
						            <subscriber-name>notsurewecare</subscriber-name>
						         </service-information>
						         <vnf-request-information>
						         	<vnf-id>${vfModuleId}</vnf-id>
									<vnf-type>${vfModuleModelName}</vnf-type>
                                    <vnf-name>${vfModuleName}</vnf-name>
									<generic-vnf-id>${vnfId}</generic-vnf-id>
                                    <generic-vnf-name>${vnfName}</generic-vnf-name>
									<generic-vnf-type>${vnfType}</generic-vnf-type>
									<aic-cloud-region>${cloudSiteId}</aic-cloud-region>
									<tenant>${tenantId}</tenant>
						         </vnf-request-information>
						      </sdncadapterworkflow:SDNCRequestData>
						   </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""

		utils.log("DEBUG", "sdncAdapterWorkflowRequest: " + request, isDebugEnabled)
		utils.logAudit("DoCreateVfModuleRollback sdncAdapterWorkflow Request: " + request)
		execution.setVariable("sdncAdapterWorkflowRequest", request)
	}

	// parse the incoming DELETE_VF_MODULE request
	// and formulate the outgoing VnfAdapterDeleteV1 request
	public void prepVNFAdapterRequest(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		String requestId = UUID.randomUUID().toString()
		String origRequestId = execution.getVariable("DCVFMR_requestId")
		String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")
		String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId")
		String vnfId = execution.getVariable("DCVFMR_vnfId")
		String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
		String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId")
		String tenantId = execution.getVariable("DCVFMR_tenantId")
		def messageId = execution.getVariable('mso-request-id') + '-' +
			System.currentTimeMillis()
		def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
		def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
		if ('true'.equals(useQualifiedHostName)) {
			notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
		}

		String request = """
			<deleteVfModuleRequest>
			    <cloudSiteId>${aicCloudRegion}</cloudSiteId>
			    <tenantId>${tenantId}</tenantId>
			    <vnfId>${vnfId}</vnfId>
			    <vfModuleId>${vfModuleId}</vfModuleId>
			    <vfModuleStackId>${vfModuleStackId}</vfModuleStackId>
			    <skipAAI>true</skipAAI>
			    <msoRequest>
			        <requestId>${origRequestId}</requestId>
			        <serviceInstanceId>${srvInstId}</serviceInstanceId>
			    </msoRequest>
			    <messageId>${messageId}</messageId>
			    <notificationUrl>${notificationUrl}</notificationUrl>
			</deleteVfModuleRequest>
			""" as String

		utils.log("DEBUG", "vnfAdapterRestV1Request: " + request, isDebugEnabled)
		utils.logAudit("PrepareUpdateAAIVfModule vnfAdapterRestV1 Request: " + request)
		execution.setVariable("vnfAdapterRestV1Request", request)
	}

	// parse the incoming DELETE_VF_MODULE request
	// and formulate the outgoing UpdateAAIVfModuleRequest request
	public void prepUpdateAAIVfModule(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		String vnfId = execution.getVariable("DCVFMR_vnfId")
		String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
		// formulate the request for UpdateAAIVfModule
		String request = """<UpdateAAIVfModuleRequest>
								<vnf-id>${vnfId}</vnf-id>
								<vf-module-id>${vfModuleId}</vf-module-id>
								<heat-stack-id>DELETE</heat-stack-id>
								<orchestration-status>deleted</orchestration-status>
							</UpdateAAIVfModuleRequest>""" as String
		utils.log("DEBUG", "UpdateAAIVfModuleRequest :" + request, isDebugEnabled)
		utils.logAudit("UpdateAAIVfModule Request: " + request)
		execution.setVariable("UpdateAAIVfModuleRequest", request)
	}

	// parse the incoming DELETE_VF_MODULE request
	// and formulate the outgoing DeleteAAIVfModuleRequest request
	public void prepDeleteAAIVfModule(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		String vnfId = execution.getVariable("DCVFMR_vnfId")
		String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
		// formulate the request for UpdateAAIVfModule
		String request = """<DeleteAAIVfModuleRequest>
								<vnf-id>${vnfId}</vnf-id>
								<vf-module-id>${vfModuleId}</vf-module-id>
							</DeleteAAIVfModuleRequest>""" as String
		utils.log("DEBUG", "DeleteAAIVfModuleRequest :" + request, isDebugEnabled)
		utils.logAudit("DeleteAAIVfModule Request: " + request)
		execution.setVariable("DeleteAAIVfModuleRequest", request)
	}

	// generates a WorkflowException if
	//		-
	public void handleDoDeleteVfModuleFailure(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: "
			+ execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), isDebugEnabled)
		String processKey = getProcessKey(execution);
		exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule")

	}

	public void sdncValidateResponse(Execution execution, String response){
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix",Prefix)

		WorkflowException workflowException = execution.getVariable("WorkflowException")
		boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")

		SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
		sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)

		if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
			utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled)
		}else{
			throw new BpmnError("MSOWorkflowException")
		}
	}

	public void deleteNetworkPoliciesFromAAI(Execution execution) {
		def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' +
		'execution=' + execution.getId() +
		')'
		def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
		logDebug('Entered ' + method, isDebugLogEnabled)
		execution.setVariable("prefix", Prefix)
		logDebug(" ======== STARTED deleteNetworkPoliciesFromAAI ======== ", isDebugLogEnabled)

		try {
			// get variables
			List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList")
			if (fqdnList == null) {
				logDebug("No network policies to delete", isDebugLogEnabled)
				return
			}
			int fqdnCount = fqdnList.size()

			execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount)
			logDebug("networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled)

			String aai_endpoint = execution.getVariable("URN_aai_endpoint")
			AaiUtil aaiUriUtil = new AaiUtil(this)
			String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution)

			if (fqdnCount > 0) {
				// AII loop call over contrail network policy fqdn list
				for (i in 0..fqdnCount-1) {

					int counting = i+1
					String fqdn = fqdnList[i]

					// Query AAI for this network policy FQDN

					String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8")
					utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest)
					logDebug("AAI request endpoint: "  + queryNetworkPolicyByFqdnAAIRequest, isDebugLogEnabled)

					def aaiRequestId = UUID.randomUUID().toString()
					APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest)
					int returnCode = response.getStatusCode()
					execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", returnCode)
					logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled)

					String aaiResponseAsString = response.getResponseBodyAsString()

					if (isOneOf(returnCode, 200, 201)) {
						logDebug("The return code is: "  + returnCode, isDebugLogEnabled)
						// This network policy FQDN exists in AAI - need to delete it now
						utils.logAudit(aaiResponseAsString)
						execution.setVariable(Prefix + "queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
						logDebug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled)
						// Retrieve the network policy id for this FQDN
						def networkPolicyId = utils.getNodeText1(aaiResponseAsString, "network-policy-id")
						logDebug("Deleting network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled)

						// Retrieve the resource version for this network policy
						def resourceVersion = utils.getNodeText1(aaiResponseAsString, "resource-version")
						logDebug("Deleting network-policy with resource-version " + resourceVersion, isDebugLogEnabled)

						String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") +
							"?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8")

						utils.logAudit("AAI request endpoint: " + delNetworkPolicyAAIRequest)
						logDebug("AAI request endpoint: " + delNetworkPolicyAAIRequest, isDebugLogEnabled)

						def aaiRequestIdDel = UUID.randomUUID().toString()
						logDebug("invoking DELETE call to AAI", isDebugLogEnabled)
						utils.logAudit("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest)

						APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest)

						int returnCodeDel = responseDel.getStatusCode()
						execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", returnCodeDel)
						logDebug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel, isDebugLogEnabled)

						if (isOneOf(returnCodeDel, 200, 201, 204)) {
							logDebug("The return code from deleting network policy is: "  + returnCodeDel, isDebugLogEnabled)
							// This network policy was deleted from AAI successfully
							logDebug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ", isDebugLogEnabled)

						} else {
								// aai all errors
								String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel
							 logDebug(delErrorMessage, isDebugLogEnabled)
							 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
						}
					} else if (returnCode == 404) {
						// This network policy FQDN is not in AAI. No need to delete.
						logDebug("The return code is: "  + returnCode, isDebugLogEnabled)
						logDebug("This network policy FQDN is not in AAI: " + fqdn, isDebugLogEnabled)
						utils.logAudit("Network policy FQDN is not in AAI")
					} else {
					   if (aaiResponseAsString.contains("RESTFault")) {
						   WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
						   execution.setVariable("WorkflowException", exceptionObject)
						   throw new BpmnError("MSOWorkflowException")

						   } else {
								// aai all errors
								String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode
								logDebug(dataErrorMessage, isDebugLogEnabled)
								exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)

						  }
					}



				} // end loop


			} else {
				   logDebug("No contrail network policies to query/create", isDebugLogEnabled)

			}

		} catch (BpmnError e) {
			throw e;

		} catch (Exception ex) {
			String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage()
			logDebug(exceptionMessage, isDebugLogEnabled)
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
		}

	}


	/**
	 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
	 *
	 * @param execution The flow's execution instance.
	 */
	public void preProcessUpdateAAIGenericVnf(Execution execution) {
		def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' +
			'execution=' + execution.getId() +
			')'
		def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
		logDebug('Entered ' + method, isDebugLogEnabled)

		try {
			def vnfId = execution.getVariable('DCVFMR_vnfId')
			def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address')
			def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address')
			def ipv4OamAddressElement = ''
			def managementV6AddressElement = ''

			if (oamManagementV4Address != null) {
				ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>'
			}

			if (oamManagementV6Address != null) {
				managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>'
			}


			String updateAAIGenericVnfRequest = """
					<UpdateAAIGenericVnfRequest>
						<vnf-id>${vnfId}</vnf-id>
						${ipv4OamAddressElement}
						${managementV6AddressElement}
					</UpdateAAIGenericVnfRequest>
				"""
				updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
				execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
				utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
				logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)


			logDebug('Exited ' + method, isDebugLogEnabled)
		} catch (BpmnError e) {
			throw e;
		} catch (Exception e) {
			logError('Caught exception in ' + method, e)
			exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage())
		}
	}
}