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
23 import static org.apache.commons.lang3.StringUtils.*
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.so.bpmn.common.scripts.AaiUtil
28 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
29 import org.onap.so.bpmn.common.scripts.ExceptionUtil
30 import org.onap.so.bpmn.common.scripts.MsoUtils
31 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
32 import org.onap.so.bpmn.common.scripts.VidUtils
33 import org.onap.so.bpmn.core.RollbackData
34 import org.onap.so.bpmn.core.UrnPropertiesReader
35 import org.onap.so.bpmn.core.WorkflowException
36 import org.onap.so.bpmn.core.domain.VnfResource
37 import org.onap.so.bpmn.core.json.JsonUtils
38 import org.onap.so.logger.MessageEnum
39 import org.onap.so.logger.MsoLogger
40 import org.onap.so.client.aai.AAIObjectType;
41 import org.onap.so.client.aai.AAIResourcesClient
42 import org.onap.so.client.aai.entities.AAIResultWrapper
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
45 import org.springframework.web.util.UriUtils
46 import org.json.JSONObject
50 * This class supports the DoCreateVnf building block subflow
51 * with the creation of a generic vnf for
55 class DoCreateVnf extends AbstractServiceTaskProcessor {
57 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnf.class);
58 String Prefix="DoCVNF_"
59 ExceptionUtil exceptionUtil = new ExceptionUtil()
60 JsonUtils jsonUtil = new JsonUtils()
61 VidUtils vidUtils = new VidUtils(this)
62 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
65 * This method gets and validates the incoming
71 public void preProcessRequest(DelegateExecution execution) {
72 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
73 execution.setVariable("prefix",Prefix)
74 msoLogger.debug("STARTED DoCreateVnf PreProcessRequest Process")
76 // DISABLE SDNC INTERACTION FOR NOW
77 execution.setVariable("SDNCInteractionEnabled", false)
84 def rollbackData = execution.getVariable("rollbackData")
85 if (rollbackData == null) {
86 rollbackData = new RollbackData()
89 String vnfModelInfo = execution.getVariable("vnfModelInfo")
90 String serviceModelInfo = execution.getVariable("serviceModelInfo")
92 String requestId = execution.getVariable("msoRequestId")
93 execution.setVariable("DoCVNF_requestId", requestId)
94 execution.setVariable("mso-request-id", requestId)
95 msoLogger.debug("Incoming Request Id is: " + requestId)
97 String serviceInstanceId = execution.getVariable("serviceInstanceId")
98 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
99 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
100 msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
102 String vnfType = execution.getVariable("vnfType")
103 execution.setVariable("DoCVNF_vnfType", vnfType)
104 msoLogger.debug("Incoming Vnf Type is: " + vnfType)
106 String vnfName = execution.getVariable("vnfName")
107 if (vnfName.equals("") || vnfName.equals("null")) {
110 execution.setVariable("DoCVNF_vnfName", vnfName)
111 msoLogger.debug("Incoming Vnf Name is: " + vnfName)
113 String serviceId = execution.getVariable("productFamilyId")
114 execution.setVariable("DoCVNF_serviceId", serviceId)
115 msoLogger.debug("Incoming Service Id is: " + serviceId)
117 String source = "VID"
118 execution.setVariable("DoCVNF_source", source)
119 rollbackData.put("VNF", "source", source)
120 msoLogger.debug("Incoming Source is: " + source)
122 String suppressRollback = execution.getVariable("disableRollback")
123 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
124 msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback)
126 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
127 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
128 msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
130 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
131 if (modelVersionId == null) {
134 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
135 msoLogger.debug("Incoming Version Id is: " + modelVersionId)
137 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
138 execution.setVariable("DoCVNF_modelVersion", modelVersion)
139 msoLogger.debug("Incoming Model Version is: " + modelVersion)
141 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
142 execution.setVariable("DoCVNF_modelName", modelName)
143 msoLogger.debug("Incoming Model Name is: " + modelName)
145 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
146 if (modelCustomizationId == null) {
147 modelCustomizationId = ""
149 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
150 msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
152 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
153 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
154 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
155 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
157 String tenantId = execution.getVariable("tenantId")
158 execution.setVariable("DoCVNF_tenantId", tenantId)
159 rollbackData.put("VNF", "tenantId", tenantId)
160 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
162 String globalSubscriberId = execution.getVariable("globalSubscriberId")
163 if (globalSubscriberId == null) {
164 globalSubscriberId = ""
166 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
167 msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
169 String sdncVersion = execution.getVariable("sdncVersion")
170 if (sdncVersion == null) {
173 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
174 msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
176 //For Completion Handler & Fallout Handler
178 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
179 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
180 <action>CREATE</action>
181 <source>${MsoUtils.xmlEscape(source)}</source>
184 execution.setVariable("DoCVNF_requestInfo", requestInfo)
185 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
186 String orchStatus = "Created"
187 execution.setVariable("DoCVNF_orchStatus", orchStatus)
189 //TODO: Equipment Role - Should come from SDN-C Response in 1702
190 String equipmentRole = " "
191 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
192 String vnfId = execution.getVariable("testVnfId") // for junits
194 vnfId = execution.getVariable("vnfId")
195 if (isBlank(vnfId)) {
196 vnfId = UUID.randomUUID().toString()
197 msoLogger.debug("Generated Vnf Id is: " + vnfId)
200 execution.setVariable("DoCVNF_vnfId", vnfId)
202 // Setting for Sub Flow Calls
203 execution.setVariable("DoCVNF_type", "generic-vnf")
204 execution.setVariable("GENGS_type", "service-instance")
206 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
207 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
208 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
209 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
210 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
212 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
213 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
214 msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
216 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
217 String nfRole = vnfResource.getNfRole()
219 execution.setVariable("DoCVNF_nfRole", nfRole)
220 msoLogger.debug("NF Role is: " + nfRole)
222 String nfNamingCode = vnfResource.getNfNamingCode()
223 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
224 msoLogger.debug("NF Naming Code is: " + nfNamingCode)
226 String nfType = vnfResource.getNfType()
227 execution.setVariable("DoCVNF_nfType", nfType)
228 msoLogger.debug("NF Type is: " + nfType)
230 String nfFunction = vnfResource.getNfFunction()
231 execution.setVariable("DoCVNF_nfFunction", nfFunction)
232 msoLogger.debug("NF Function is: " + nfFunction)
234 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
235 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
236 rollbackData.put("VNF", "rollbackVnfCreate", "false")
238 execution.setVariable("rollbackData", rollbackData)
241 msoLogger.debug("Rethrowing MSOWorkflowException")
244 msoLogger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
245 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
248 msoLogger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
252 * Gets the service instance from aai
254 public void getServiceInstance(DelegateExecution execution) {
256 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
258 AAIResourcesClient resourceClient = new AAIResourcesClient()
259 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
261 if(resourceClient.exists(uri)){
262 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
265 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
268 }catch(BpmnError e) {
270 }catch(Exception ex) {
271 String msg = "Exception in getServiceInstance. " + ex.getMessage()
273 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
277 private Object getVariableEnforced(DelegateExecution execution, String name){
278 Object enforced = execution.getVariable(name)
285 public void createGenericVnf (DelegateExecution execution) {
286 execution.setVariable("prefix",Prefix)
287 msoLogger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
290 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
291 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
292 if (vnfName == null) {
293 vnfName = "sdncGenerated"
294 msoLogger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
296 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
297 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
298 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
299 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
300 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
301 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
302 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
303 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
304 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
305 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
306 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
308 //Get Service Instance Info
309 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
310 String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink")
312 int custStart = siRelatedLink.indexOf("customer/")
313 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
314 String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
315 int serviceStart = siRelatedLink.indexOf("service-subscription/")
316 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
317 String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
319 Map<String, String> payload = new LinkedHashMap<>();
320 payload.put("vnf-id", vnfId);
321 payload.put("vnf-name", vnfName);
322 payload.put("service-id", serviceId);
323 payload.put("vnf-type", vnfType);
324 payload.put("prov-status", "PREPROV");
325 payload.put("orchestration-status", orchStatus);
326 payload.put("model-invariant-id", modelInvariantId);
327 payload.put("model-version-id", modelVersionId);
328 payload.put("model-customization-id", modelCustomizationId);
329 payload.put("nf-type", nfType);
330 payload.put("nf-role", nfRole);
331 payload.put("nf-function", nfFunction);
332 payload.put("nf-naming-code", nfNamingCode);
334 AAIResourcesClient resourceClient = new AAIResourcesClient();
335 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
336 resourceClient.create(uri, payload)
338 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
339 resourceClient.connect(uri, siUri)
341 }catch(Exception ex) {
342 msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process " + ex.getMessage())
343 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
345 msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
348 public void postProcessCreateGenericVnf (DelegateExecution execution) {
349 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
350 execution.setVariable("prefix",Prefix)
352 msoLogger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
355 String vnfId = execution.getVariable("DoCVNF_vnfId")
356 def rollbackData = execution.getVariable("rollbackData")
357 rollbackData.put("VNF", "vnfId", vnfId)
358 rollbackData.put("VNF", "rollbackVnfCreate", "true")
359 execution.setVariable("rollbackData", rollbackData)
360 }catch(Exception ex) {
361 msoLogger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
362 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
364 msoLogger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
368 public void preProcessSDNCAssignRequest(DelegateExecution execution){
369 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
370 execution.setVariable("prefix", Prefix)
371 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
372 def vnfId = execution.getVariable("DoCVNF_vnfId")
373 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
374 msoLogger.debug("NEW VNF ID: " + vnfId)
379 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
381 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
382 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
383 msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
386 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCAssignRequest" , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
387 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
389 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
392 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
393 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
394 'execution=' + execution.getId() +
396 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
397 msoLogger.trace('Entered ' + method)
398 execution.setVariable("prefix", Prefix)
399 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
401 String vnfId = execution.getVariable("DoCVNF_vnfId")
402 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
404 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
406 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
407 msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
410 msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
411 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
413 msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process")
416 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
418 String uuid = execution.getVariable('testReqId') // for junits
420 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
422 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
423 def requestId = execution.getVariable("DoCVNF_requestId")
424 def serviceId = execution.getVariable("DoCVNF_serviceId")
425 def vnfType = execution.getVariable("DoCVNF_vnfType")
426 def vnfName = execution.getVariable("DoCVNF_vnfName")
427 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
428 String vnfNameString = ""
429 if (vnfName != null) {
430 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
432 def tenantId = execution.getVariable("DoCVNF_tenantId")
433 def source = execution.getVariable("DoCVNF_source")
434 def vnfId = execution.getVariable("DoCVNF_vnfId")
435 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
436 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
437 def serviceModelInfo = execution.getVariable("serviceModelInfo")
438 def vnfModelInfo = execution.getVariable("vnfModelInfo")
439 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
440 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
441 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
442 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
444 String sdncVNFParamsXml = ""
446 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
447 sdncVNFParamsXml = buildSDNCParamsXml(execution)
449 sdncVNFParamsXml = ""
453 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
454 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
455 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
456 <sdncadapter:RequestHeader>
457 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
458 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
459 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
460 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
461 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
462 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
463 </sdncadapter:RequestHeader>
464 <sdncadapterworkflow:SDNCRequestData>
465 <request-information>
466 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
467 <request-action>CreateVnfInstance</request-action>
468 <source>${MsoUtils.xmlEscape(source)}</source>
472 </request-information>
473 <service-information>
474 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
475 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
476 ${serviceEcompModelInformation}
477 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
478 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
479 </service-information>
481 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
482 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
483 ${vnfEcompModelInformation}
487 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
488 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
491 </sdncadapterworkflow:SDNCRequestData>
492 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
494 msoLogger.debug("sdncRequest: " + sdncRequest)
498 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
499 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
500 execution.setVariable("prefix",Prefix)
501 msoLogger.debug("STARTED ValidateSDNCResponse Process")
503 WorkflowException workflowException = execution.getVariable("WorkflowException")
504 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
506 msoLogger.debug("workflowException: " + workflowException)
508 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
509 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
511 msoLogger.debug("SDNCResponse: " + response)
513 String sdncResponse = response
514 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
515 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
516 if(method.equals("get")){
517 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
518 String data = utils.getNodeXml(topologyGetResponse, "response-data")
519 msoLogger.debug("topologyGetResponseData: " + data)
520 String vnfName = utils.getNodeText(data, "vnf-name")
521 msoLogger.debug("vnfName received from SDNC: " + vnfName)
522 execution.setVariable("vnfName", vnfName)
523 execution.setVariable("DoCVNF_vnfName", vnfName)
525 def rollbackData = execution.getVariable("rollbackData")
526 if (method.equals("assign")) {
527 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
529 else if (method.equals("activate")) {
530 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
532 execution.setVariable("rollbackData", rollbackData)
536 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
537 throw new BpmnError("MSOWorkflowException")
539 msoLogger.debug("COMPLETED ValidateSDNCResponse Process")
542 public void preProcessSDNCGetRequest(DelegateExecution execution){
543 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
544 execution.setVariable("prefix", Prefix)
545 msoLogger.trace("STARTED preProcessSDNCGetRequest Process")
547 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
549 String uuid = execution.getVariable('testReqId') // for junits
551 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
554 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
555 msoLogger.debug("callbackUrl:" + callbackUrl)
557 def vnfId = execution.getVariable('DCVFM_vnfId')
560 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
564 svcInstId = serviceInstanceId
566 // serviceOperation will be retrieved from "object-path" element
567 // in SDNC Assign Response for VNF
568 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
569 msoLogger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
571 String serviceOperation = ""
573 String data = utils.getNodeXml(response, "response-data")
574 msoLogger.debug("responseData: " + data)
575 serviceOperation = utils.getNodeText(data, "object-path")
576 msoLogger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
579 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
582 String SDNCGetRequest =
583 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
584 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
585 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
586 <sdncadapter:RequestHeader>
587 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
588 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
589 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
590 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
591 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
592 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
593 </sdncadapter:RequestHeader>
594 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
595 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
598 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
599 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
602 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
603 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
605 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
609 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
611 * @param execution The flow's execution instance.
613 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
614 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
615 'execution=' + execution.getId() +
617 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
618 msoLogger.trace('Entered ' + method)
621 def vnfId = execution.getVariable('DoCVNF_vnfId')
622 msoLogger.debug("VNF ID: " + vnfId)
624 String updateAAIGenericVnfRequest = """
625 <UpdateAAIGenericVnfRequest>
626 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
627 <orchestration-status>Active</orchestration-status>
628 </UpdateAAIGenericVnfRequest>
630 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
631 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
632 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
635 msoLogger.trace('Exited ' + method)
636 } catch (BpmnError e) {
638 } catch (Exception e) {
639 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
640 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())