2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
22 import org.camunda.bpm.engine.delegate.BpmnError
23 import org.camunda.bpm.engine.delegate.DelegateExecution
24 import org.onap.aai.domain.yang.NetworkPolicies
25 import org.onap.aai.domain.yang.NetworkPolicy
26 import org.onap.so.bpmn.common.scripts.AaiUtil
27 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
28 import org.onap.so.bpmn.common.scripts.ExceptionUtil
29 import org.onap.so.bpmn.common.scripts.MsoUtils
30 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
31 import org.onap.so.bpmn.core.UrnPropertiesReader
32 import org.onap.so.bpmn.core.WorkflowException
33 import org.onap.so.client.aai.AAIObjectPlurals
34 import org.onap.so.client.aai.AAIObjectType
35 import org.onap.so.client.aai.entities.uri.AAIResourceUri
36 import org.onap.so.client.aai.entities.uri.AAIUriFactory
37 import org.onap.so.logger.MessageEnum
38 import org.onap.so.logger.MsoLogger
39 import org.onap.so.rest.APIResponse
40 import org.springframework.web.util.UriUtils
42 import javax.ws.rs.NotFoundException
45 public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
46 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleRollback.class);
49 ExceptionUtil exceptionUtil = new ExceptionUtil()
51 public void initProcessVariables(DelegateExecution execution) {
52 execution.setVariable("prefix",Prefix)
55 // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids
56 // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest
57 public void preProcessRequest(DelegateExecution execution) {
60 initProcessVariables(execution)
64 execution.setVariable("rolledBack", null)
65 execution.setVariable("rollbackError", null)
67 def rollbackData = execution.getVariable("rollbackData")
68 msoLogger.debug("RollbackData:" + rollbackData)
70 if (rollbackData != null) {
71 String vnfId = rollbackData.get("VFMODULE", "vnfid")
72 execution.setVariable("DCVFMR_vnfId", vnfId)
73 String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid")
74 execution.setVariable("DCVFMR_vfModuleId", vfModuleId)
75 String source = rollbackData.get("VFMODULE", "source")
76 execution.setVariable("DCVFMR_source", source)
77 String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId")
78 execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId)
79 String serviceId = rollbackData.get("VFMODULE", "service-id")
80 execution.setVariable("DCVFMR_serviceId", serviceId)
81 String vnfType = rollbackData.get("VFMODULE", "vnftype")
82 execution.setVariable("DCVFMR_vnfType", vnfType)
83 String vnfName = rollbackData.get("VFMODULE", "vnfname")
84 execution.setVariable("DCVFMR_vnfName", vnfName)
85 String tenantId = rollbackData.get("VFMODULE", "tenantid")
86 execution.setVariable("DCVFMR_tenantId", tenantId)
87 String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename")
88 execution.setVariable("DCVFMR_vfModuleName", vfModuleName)
89 String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname")
90 execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName)
91 String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion")
92 execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId)
93 String heatStackId = rollbackData.get("VFMODULE", "heatstackid")
94 execution.setVariable("DCVFMR_heatStackId", heatStackId)
95 String requestId = rollbackData.get("VFMODULE", "msorequestid")
96 execution.setVariable("DCVFMR_requestId", requestId)
97 // Set mso-request-id to request-id for VNF Adapter interface
98 execution.setVariable("mso-request-id", requestId)
99 List createdNetworkPolicyFqdnList = []
102 String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i)
106 createdNetworkPolicyFqdnList.add(fqdn)
107 msoLogger.debug("got fqdn # " + i + ": " + fqdn)
112 execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList)
113 String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address")
114 execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address)
115 String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address")
116 execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address)
117 //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid")
118 //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId)
119 execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule"))
120 execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule"))
121 execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate"))
122 execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign"))
123 execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate"))
124 execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule"))
125 execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI"))
126 execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI"))
128 // formulate the request for PrepareUpdateAAIVfModule
129 String request = """<PrepareUpdateAAIVfModuleRequest>
130 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
131 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
132 <orchestration-status>pending-delete</orchestration-status>
133 </PrepareUpdateAAIVfModuleRequest>""" as String
134 msoLogger.debug("PrepareUpdateAAIVfModuleRequest :" + request)
135 execution.setVariable("PrepareUpdateAAIVfModuleRequest", request)
137 execution.setVariable("skipRollback", true)
140 if (execution.getVariable("disableRollback").equals("true" )) {
141 execution.setVariable("skipRollback", true)
144 } catch (BpmnError e) {
146 } catch (Exception ex){
147 def msg = "Exception in DoCreateVfModuleRollback preProcessRequest " + ex.getMessage()
149 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
153 // build a SDNC vnf-topology-operation request for the specified action
154 // (note: the action passed is expected to be 'changedelete' or 'delete')
155 public void prepSDNCAdapterRequest(DelegateExecution execution) {
157 String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")
159 String uuid = execution.getVariable('testReqId') // for junits
161 uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis()
164 def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
166 String source = execution.getVariable("DCVFMR_source")
167 String serviceId = execution.getVariable("DCVFMR_serviceId")
168 String vnfId = execution.getVariable("DCVFMR_vnfId")
169 String vnfType = execution.getVariable("DCVFMR_vnfType")
170 String vnfName = execution.getVariable("DCVFMR_vnfName")
171 String tenantId = execution.getVariable("DCVFMR_tenantId")
172 String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
173 String vfModuleName = execution.getVariable("DCVFMR_vfModuleName")
174 String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName")
175 String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId")
176 String requestId = execution.getVariable("DCVFMR_requestId")
178 String serviceInstanceIdToSdnc = ""
179 if (srvInstId != null && !srvInstId.isEmpty()) {
180 serviceInstanceIdToSdnc = srvInstId
182 serviceInstanceIdToSdnc = vfModuleId
185 def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate")
186 def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign")
189 def requestAction = ""
191 if (doSDNCActivateRollback.equals("true")) {
193 requestAction = "DisconnectVNFRequest"
195 else if (doSDNCAssignRollback.equals("true")) {
197 requestAction = "VNFActivateRequest"
203 String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
204 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
205 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
206 <sdncadapter:RequestHeader>
207 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
208 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(vfModuleId)}</sdncadapter:SvcInstanceId>
209 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
210 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
211 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
212 </sdncadapter:RequestHeader>
213 <sdncadapterworkflow:SDNCRequestData>
214 <request-information>
215 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
216 <request-action>${MsoUtils.xmlEscape(requestAction)}</request-action>
217 <source>${MsoUtils.xmlEscape(source)}</source>
221 </request-information>
222 <service-information>
223 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
224 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
225 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceIdToSdnc)}</service-instance-id>
226 <subscriber-name>notsurewecare</subscriber-name>
227 </service-information>
228 <vnf-request-information>
229 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
230 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
231 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
232 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
233 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
234 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
235 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
236 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
237 </vnf-request-information>
238 </sdncadapterworkflow:SDNCRequestData>
239 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
241 msoLogger.debug("sdncAdapterWorkflowRequest: " + request)
242 execution.setVariable("sdncAdapterWorkflowRequest", request)
245 public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
247 execution.setVariable("prefix", Prefix)
248 msoLogger.trace("STARTED preProcessSDNCDeactivateRequest")
250 def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId")
255 String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
257 deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
258 execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest)
259 msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
262 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
263 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
265 msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest")
268 public void preProcessSDNCUnassignRequest(DelegateExecution execution) {
269 def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' +
270 'execution=' + execution.getId() +
272 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
273 msoLogger.trace('Entered ' + method)
274 execution.setVariable("prefix", Prefix)
275 msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process")
277 String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId")
279 String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
281 execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest)
282 msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
285 msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e)
286 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
288 msoLogger.trace("COMPLETED preProcessSDNCUnassignRequest Process")
291 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
293 String uuid = execution.getVariable('testReqId') // for junits
295 uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis()
297 def callbackURL = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
298 def requestId = execution.getVariable("DCVFMR_requestId")
299 def serviceId = execution.getVariable("DCVFMR_serviceId")
300 def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId")
301 def vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
302 def source = execution.getVariable("DCVFMR_source")
303 def vnfId = execution.getVariable("DCVFMR_vnfId")
305 def sdncVersion = execution.getVariable("sdncVersion")
308 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
309 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
310 xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1">
311 <sdncadapter:RequestHeader>
312 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
313 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
314 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
315 <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
316 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
317 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
318 </sdncadapter:RequestHeader>
319 <sdncadapterworkflow:SDNCRequestData>
320 <request-information>
321 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
322 <request-action>DeleteVfModuleInstance</request-action>
323 <source>${MsoUtils.xmlEscape(source)}</source>
327 </request-information>
328 <service-information>
330 <subscription-service-type/>
331 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
332 <global-customer-id/>
333 </service-information>
335 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
338 <vf-module-information>
339 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
340 </vf-module-information>
341 <vf-module-request-input/>
342 </sdncadapterworkflow:SDNCRequestData>
343 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
345 msoLogger.debug("sdncRequest: " + sdncRequest)
349 // parse the incoming DELETE_VF_MODULE request
350 // and formulate the outgoing VnfAdapterDeleteV1 request
351 public void prepVNFAdapterRequest(DelegateExecution execution) {
353 String requestId = UUID.randomUUID().toString()
354 String origRequestId = execution.getVariable("DCVFMR_requestId")
355 String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")
356 String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId")
357 String vnfId = execution.getVariable("DCVFMR_vnfId")
358 String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
359 String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId")
360 String tenantId = execution.getVariable("DCVFMR_tenantId")
361 def messageId = execution.getVariable('mso-request-id') + '-' +
362 System.currentTimeMillis()
363 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
364 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
365 if ('true'.equals(useQualifiedHostName)) {
366 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
370 <deleteVfModuleRequest>
371 <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId>
372 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
373 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
374 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
375 <vfModuleStackId>${MsoUtils.xmlEscape(vfModuleStackId)}</vfModuleStackId>
376 <skipAAI>true</skipAAI>
378 <requestId>${MsoUtils.xmlEscape(origRequestId)}</requestId>
379 <serviceInstanceId>${MsoUtils.xmlEscape(srvInstId)}</serviceInstanceId>
381 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
382 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
383 </deleteVfModuleRequest>
386 msoLogger.debug("vnfAdapterRestV1Request: " + request)
387 execution.setVariable("vnfAdapterRestV1Request", request)
390 // parse the incoming DELETE_VF_MODULE request
391 // and formulate the outgoing UpdateAAIVfModuleRequest request
392 public void prepUpdateAAIVfModule(DelegateExecution execution) {
394 String vnfId = execution.getVariable("DCVFMR_vnfId")
395 String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
396 // formulate the request for UpdateAAIVfModule
397 String request = """<UpdateAAIVfModuleRequest>
398 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
399 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
400 <heat-stack-id>DELETE</heat-stack-id>
401 <orchestration-status>deleted</orchestration-status>
402 </UpdateAAIVfModuleRequest>""" as String
403 msoLogger.debug("UpdateAAIVfModuleRequest :" + request)
404 execution.setVariable("UpdateAAIVfModuleRequest", request)
407 // parse the incoming DELETE_VF_MODULE request
408 // and formulate the outgoing UpdateAAIVfModuleRequest request
409 public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) {
411 String vnfId = execution.getVariable("DCVFMR_vnfId")
412 String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
413 // formulate the request for UpdateAAIVfModule
414 String request = """<UpdateAAIVfModuleRequest>
415 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
416 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
417 <heat-stack-id></heat-stack-id>
418 <orchestration-status>Assigned</orchestration-status>
419 </UpdateAAIVfModuleRequest>""" as String
420 msoLogger.debug("UpdateAAIVfModuleRequest :" + request)
421 execution.setVariable("UpdateAAIVfModuleRequest", request)
424 // parse the incoming DELETE_VF_MODULE request
425 // and formulate the outgoing DeleteAAIVfModuleRequest request
426 public void prepDeleteAAIVfModule(DelegateExecution execution) {
428 String vnfId = execution.getVariable("DCVFMR_vnfId")
429 String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
430 // formulate the request for UpdateAAIVfModule
431 String request = """<DeleteAAIVfModuleRequest>
432 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
433 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
434 </DeleteAAIVfModuleRequest>""" as String
435 msoLogger.debug("DeleteAAIVfModuleRequest :" + request)
436 execution.setVariable("DeleteAAIVfModuleRequest", request)
439 // generates a WorkflowException if
441 public void handleDoDeleteVfModuleFailure(DelegateExecution execution) {
443 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf"+ execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
444 String processKey = getProcessKey(execution);
445 exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule")
449 public void sdncValidateResponse(DelegateExecution execution, String response){
451 execution.setVariable("prefix",Prefix)
453 WorkflowException workflowException = execution.getVariable("WorkflowException")
454 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
456 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
457 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
459 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
460 msoLogger.debug("Successfully Validated SDNC Response")
462 throw new BpmnError("MSOWorkflowException")
466 public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) {
467 def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' +
468 'execution=' + execution.getId() +
470 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
471 msoLogger.trace('Entered ' + method)
472 execution.setVariable("prefix", Prefix)
473 msoLogger.trace("STARTED deleteNetworkPoliciesFromAAI")
477 List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList")
478 if (fqdnList == null) {
479 msoLogger.debug("No network policies to delete")
482 int fqdnCount = fqdnList.size()
484 execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount)
485 msoLogger.debug("networkPolicyFqdnCount - " + fqdnCount)
487 AaiUtil aaiUriUtil = new AaiUtil(this)
490 // AII loop call over contrail network policy fqdn list
491 for (i in 0..fqdnCount-1) {
494 String fqdn = fqdnList[i]
497 // Query AAI for this network policy FQDN
498 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
499 uri.queryParam("network-policy-fqdn", fqdn)
500 Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
502 if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) {
503 execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", 200)
504 NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0)
507 AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
508 getAAIClient().delete(delUri)
509 execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 200)
510 msoLogger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200)
511 msoLogger.debug("The return code from deleting network policy is: " + 200)
512 // This network policy was deleted from AAI successfully
513 msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
514 }catch(NotFoundException ne){
515 // This network policy FQDN is not in AAI. No need to delete.
516 execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 404)
517 msoLogger.debug("The return code is: " + 404)
518 msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
521 String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage()
522 msoLogger.debug(delErrorMessage)
523 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
526 // This network policy FQDN is not in AAI. No need to delete.
527 msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
529 }catch (BpmnError e){
532 catch (Exception e) {
534 String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage()
535 msoLogger.debug(dataErrorMessage)
536 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
542 msoLogger.debug("No contrail network policies to query/create")
546 } catch (BpmnError e) {
549 } catch (Exception ex) {
550 String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage()
551 msoLogger.debug(exceptionMessage)
552 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
559 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
561 * @param execution The flow's execution instance.
563 public void preProcessUpdateAAIGenericVnf(DelegateExecution execution) {
564 def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' +
565 'execution=' + execution.getId() +
567 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
568 msoLogger.trace('Entered ' + method)
571 def vnfId = execution.getVariable('DCVFMR_vnfId')
572 def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address')
573 def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address')
574 def ipv4OamAddressElement = ''
575 def managementV6AddressElement = ''
577 if (oamManagementV4Address != null) {
578 ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>'
581 if (oamManagementV6Address != null) {
582 managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>'
586 String updateAAIGenericVnfRequest = """
587 <UpdateAAIGenericVnfRequest>
588 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
589 ${ipv4OamAddressElement}
590 ${managementV6AddressElement}
591 </UpdateAAIGenericVnfRequest>
593 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
594 execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
595 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
598 msoLogger.trace('Exited ' + method)
599 } catch (BpmnError e) {
601 } catch (Exception e) {
602 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
603 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage())
607 public void setSuccessfulRollbackStatus (DelegateExecution execution){
609 execution.setVariable("prefix", Prefix)
610 msoLogger.trace("STARTED setSuccessfulRollbackStatus")
613 // Set rolledBack to true, rollbackError to null
614 execution.setVariable("rolledBack", true)
615 execution.setVariable("rollbackError", null)
618 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
619 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage())
621 msoLogger.trace("COMPLETED setSuccessfulRollbackStatus")
624 public void setFailedRollbackStatus (DelegateExecution execution){
626 execution.setVariable("prefix", Prefix)
627 msoLogger.trace("STARTED setFailedRollbackStatus")
630 // Set rolledBack to false, rollbackError to actual value, rollbackData to null
631 execution.setVariable("rolledBack", false)
632 execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback')
633 execution.setVariable("rollbackData", null)
636 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setFailedRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
637 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage())
639 msoLogger.trace("COMPLETED setFailedRollbackStatus")