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.aai.domain.yang.GenericVnf
28 import org.onap.so.bpmn.common.scripts.AaiUtil
29 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.onap.so.bpmn.common.scripts.ExceptionUtil
31 import org.onap.so.bpmn.common.scripts.MsoUtils
32 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
33 import org.onap.so.bpmn.common.scripts.VidUtils
34 import org.onap.so.bpmn.core.RollbackData
35 import org.onap.so.bpmn.core.UrnPropertiesReader
36 import org.onap.so.bpmn.core.WorkflowException
37 import org.onap.so.bpmn.core.domain.VnfResource
38 import org.onap.so.bpmn.core.json.JsonUtils
39 import org.onap.so.logger.MessageEnum
40 import org.onap.so.logger.MsoLogger
41 import org.onap.so.client.aai.AAIObjectType;
42 import org.onap.so.client.aai.AAIResourcesClient
43 import org.onap.so.client.aai.entities.AAIResultWrapper
44 import org.onap.so.client.aai.entities.uri.AAIResourceUri
45 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
46 import org.springframework.web.util.UriUtils
47 import org.json.JSONObject
51 * This class supports the DoCreateVnf building block subflow
52 * with the creation of a generic vnf for
56 class DoCreateVnf extends AbstractServiceTaskProcessor {
58 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnf.class);
59 String Prefix="DoCVNF_"
60 ExceptionUtil exceptionUtil = new ExceptionUtil()
61 JsonUtils jsonUtil = new JsonUtils()
62 VidUtils vidUtils = new VidUtils(this)
63 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
66 * This method gets and validates the incoming
72 public void preProcessRequest(DelegateExecution execution) {
73 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
74 execution.setVariable("prefix",Prefix)
75 msoLogger.debug("STARTED DoCreateVnf PreProcessRequest Process")
77 // DISABLE SDNC INTERACTION FOR NOW
78 execution.setVariable("SDNCInteractionEnabled", false)
85 def rollbackData = execution.getVariable("rollbackData")
86 if (rollbackData == null) {
87 rollbackData = new RollbackData()
90 String vnfModelInfo = execution.getVariable("vnfModelInfo")
91 String serviceModelInfo = execution.getVariable("serviceModelInfo")
93 String requestId = execution.getVariable("msoRequestId")
94 execution.setVariable("DoCVNF_requestId", requestId)
95 execution.setVariable("mso-request-id", requestId)
96 msoLogger.debug("Incoming Request Id is: " + requestId)
98 String serviceInstanceId = execution.getVariable("serviceInstanceId")
99 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
100 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
101 msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
103 String vnfType = execution.getVariable("vnfType")
104 execution.setVariable("DoCVNF_vnfType", vnfType)
105 msoLogger.debug("Incoming Vnf Type is: " + vnfType)
107 String vnfName = execution.getVariable("vnfName")
108 if (vnfName.equals("") || vnfName.equals("null")) {
109 AAIResourcesClient resourceClient = new AAIResourcesClient()
110 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId"))
111 if(resourceClient.exists(uri)){
112 exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")
117 execution.setVariable("DoCVNF_vnfName", vnfName)
118 msoLogger.debug("Incoming Vnf Name is: " + vnfName)
120 String serviceId = execution.getVariable("productFamilyId")
121 execution.setVariable("DoCVNF_serviceId", serviceId)
122 msoLogger.debug("Incoming Service Id is: " + serviceId)
124 String source = "VID"
125 execution.setVariable("DoCVNF_source", source)
126 rollbackData.put("VNF", "source", source)
127 msoLogger.debug("Incoming Source is: " + source)
129 String suppressRollback = execution.getVariable("disableRollback")
130 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
131 msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback)
133 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
134 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
135 msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
137 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
138 if (modelVersionId == null) {
141 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
142 msoLogger.debug("Incoming Version Id is: " + modelVersionId)
144 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
145 execution.setVariable("DoCVNF_modelVersion", modelVersion)
146 msoLogger.debug("Incoming Model Version is: " + modelVersion)
148 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
149 execution.setVariable("DoCVNF_modelName", modelName)
150 msoLogger.debug("Incoming Model Name is: " + modelName)
152 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
153 if (modelCustomizationId == null) {
154 modelCustomizationId = ""
156 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
157 msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
159 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
160 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
161 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
162 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
164 String tenantId = execution.getVariable("tenantId")
165 execution.setVariable("DoCVNF_tenantId", tenantId)
166 rollbackData.put("VNF", "tenantId", tenantId)
167 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
169 String globalSubscriberId = execution.getVariable("globalSubscriberId")
170 if (globalSubscriberId == null) {
171 globalSubscriberId = ""
173 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
174 msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
176 String sdncVersion = execution.getVariable("sdncVersion")
177 if (sdncVersion == null) {
180 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
181 msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
183 //For Completion Handler & Fallout Handler
185 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
186 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
187 <action>CREATE</action>
188 <source>${MsoUtils.xmlEscape(source)}</source>
191 execution.setVariable("DoCVNF_requestInfo", requestInfo)
192 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
193 String orchStatus = "Created"
194 execution.setVariable("DoCVNF_orchStatus", orchStatus)
196 //TODO: Equipment Role - Should come from SDN-C Response in 1702
197 String equipmentRole = " "
198 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
199 String vnfId = execution.getVariable("testVnfId") // for junits
201 vnfId = execution.getVariable("vnfId")
202 if (isBlank(vnfId)) {
203 vnfId = UUID.randomUUID().toString()
204 msoLogger.debug("Generated Vnf Id is: " + vnfId)
207 execution.setVariable("DoCVNF_vnfId", vnfId)
209 // Setting for Sub Flow Calls
210 execution.setVariable("DoCVNF_type", "generic-vnf")
211 execution.setVariable("GENGS_type", "service-instance")
213 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
214 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
215 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
216 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
217 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
219 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
220 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
221 msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
223 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
224 String nfRole = vnfResource.getNfRole()
226 execution.setVariable("DoCVNF_nfRole", nfRole)
227 msoLogger.debug("NF Role is: " + nfRole)
229 String nfNamingCode = vnfResource.getNfNamingCode()
230 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
231 msoLogger.debug("NF Naming Code is: " + nfNamingCode)
233 String nfType = vnfResource.getNfType()
234 execution.setVariable("DoCVNF_nfType", nfType)
235 msoLogger.debug("NF Type is: " + nfType)
237 String nfFunction = vnfResource.getNfFunction()
238 execution.setVariable("DoCVNF_nfFunction", nfFunction)
239 msoLogger.debug("NF Function is: " + nfFunction)
241 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
242 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
243 rollbackData.put("VNF", "rollbackVnfCreate", "false")
245 execution.setVariable("rollbackData", rollbackData)
248 msoLogger.debug("Rethrowing MSOWorkflowException")
251 msoLogger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
252 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
255 msoLogger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
259 * Gets the service instance from aai
261 public void getServiceInstance(DelegateExecution execution) {
263 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
265 AAIResourcesClient resourceClient = new AAIResourcesClient()
266 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
268 if(resourceClient.exists(uri)){
269 Map<String, String> keys = uri.getURIKeys()
270 execution.setVariable("globalCustomerId", keys.get("global-customer-id"))
271 execution.setVariable("serviceType", keys.get("service-type"))
272 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
275 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
278 }catch(BpmnError e) {
280 }catch(Exception ex) {
281 String msg = "Exception in getServiceInstance. " + ex.getMessage()
283 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
287 private Object getVariableEnforced(DelegateExecution execution, String name){
288 Object enforced = execution.getVariable(name)
295 public void createGenericVnf (DelegateExecution execution) {
296 execution.setVariable("prefix",Prefix)
297 msoLogger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
300 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
301 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
302 if (vnfName == null) {
303 vnfName = "sdncGenerated"
304 msoLogger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
306 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
307 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
308 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
309 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
310 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
311 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
312 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
313 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
314 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
315 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
316 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
318 //Get Service Instance Info
319 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
321 String globalCustId = execution.getVariable("globalCustomerId")
322 String serviceType = execution.getVariable("serviceType")
324 Map<String, String> payload = new LinkedHashMap<>();
325 payload.put("vnf-id", vnfId);
326 payload.put("vnf-name", vnfName);
327 payload.put("service-id", serviceId);
328 payload.put("vnf-type", vnfType);
329 payload.put("prov-status", "PREPROV");
330 payload.put("orchestration-status", orchStatus);
331 payload.put("model-invariant-id", modelInvariantId);
332 payload.put("model-version-id", modelVersionId);
333 payload.put("model-customization-id", modelCustomizationId);
334 payload.put("nf-type", nfType);
335 payload.put("nf-role", nfRole);
336 payload.put("nf-function", nfFunction);
337 payload.put("nf-naming-code", nfNamingCode);
339 AAIResourcesClient resourceClient = new AAIResourcesClient();
340 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
341 resourceClient.create(uri, payload)
343 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
344 resourceClient.connect(uri, siUri)
346 }catch(Exception ex) {
347 msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex)
348 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
350 msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
353 public void postProcessCreateGenericVnf (DelegateExecution execution) {
354 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
355 execution.setVariable("prefix",Prefix)
357 msoLogger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
360 String vnfId = execution.getVariable("DoCVNF_vnfId")
361 def rollbackData = execution.getVariable("rollbackData")
362 rollbackData.put("VNF", "vnfId", vnfId)
363 rollbackData.put("VNF", "rollbackVnfCreate", "true")
364 execution.setVariable("rollbackData", rollbackData)
365 }catch(Exception ex) {
366 msoLogger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
367 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
369 msoLogger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
373 public void preProcessSDNCAssignRequest(DelegateExecution execution){
374 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
375 execution.setVariable("prefix", Prefix)
376 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
377 def vnfId = execution.getVariable("DoCVNF_vnfId")
378 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
379 msoLogger.debug("NEW VNF ID: " + vnfId)
384 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
386 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
387 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
388 msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
391 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCAssignRequest" , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
392 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
394 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
397 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
398 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
399 'execution=' + execution.getId() +
401 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
402 msoLogger.trace('Entered ' + method)
403 execution.setVariable("prefix", Prefix)
404 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
406 String vnfId = execution.getVariable("DoCVNF_vnfId")
407 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
409 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
411 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
412 msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
415 msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
416 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
418 msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process")
421 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
423 String uuid = execution.getVariable('testReqId') // for junits
425 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
427 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
428 def requestId = execution.getVariable("DoCVNF_requestId")
429 def serviceId = execution.getVariable("DoCVNF_serviceId")
430 def vnfType = execution.getVariable("DoCVNF_vnfType")
431 def vnfName = execution.getVariable("DoCVNF_vnfName")
432 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
433 String vnfNameString = ""
434 if (vnfName != null) {
435 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
437 def tenantId = execution.getVariable("DoCVNF_tenantId")
438 def source = execution.getVariable("DoCVNF_source")
439 def vnfId = execution.getVariable("DoCVNF_vnfId")
440 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
441 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
442 def serviceModelInfo = execution.getVariable("serviceModelInfo")
443 def vnfModelInfo = execution.getVariable("vnfModelInfo")
444 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
445 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
446 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
447 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
449 String sdncVNFParamsXml = ""
451 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
452 sdncVNFParamsXml = buildSDNCParamsXml(execution)
454 sdncVNFParamsXml = ""
458 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
459 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
460 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
461 <sdncadapter:RequestHeader>
462 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
463 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
464 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
465 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
466 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
467 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
468 </sdncadapter:RequestHeader>
469 <sdncadapterworkflow:SDNCRequestData>
470 <request-information>
471 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
472 <request-action>CreateVnfInstance</request-action>
473 <source>${MsoUtils.xmlEscape(source)}</source>
477 </request-information>
478 <service-information>
479 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
480 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
481 ${serviceEcompModelInformation}
482 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
483 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
484 </service-information>
486 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
487 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
488 ${vnfEcompModelInformation}
492 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
493 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
496 </sdncadapterworkflow:SDNCRequestData>
497 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
499 msoLogger.debug("sdncRequest: " + sdncRequest)
503 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
504 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
505 execution.setVariable("prefix",Prefix)
506 msoLogger.debug("STARTED ValidateSDNCResponse Process")
508 WorkflowException workflowException = execution.getVariable("WorkflowException")
509 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
511 msoLogger.debug("workflowException: " + workflowException)
513 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
514 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
516 msoLogger.debug("SDNCResponse: " + response)
518 String sdncResponse = response
519 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
520 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
521 if(method.equals("get")){
522 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
523 String data = utils.getNodeXml(topologyGetResponse, "response-data")
524 msoLogger.debug("topologyGetResponseData: " + data)
525 String vnfName = utils.getNodeText(data, "vnf-name")
526 msoLogger.debug("vnfName received from SDNC: " + vnfName)
527 execution.setVariable("vnfName", vnfName)
528 execution.setVariable("DoCVNF_vnfName", vnfName)
530 def rollbackData = execution.getVariable("rollbackData")
531 if (method.equals("assign")) {
532 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
534 else if (method.equals("activate")) {
535 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
537 execution.setVariable("rollbackData", rollbackData)
541 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
542 throw new BpmnError("MSOWorkflowException")
544 msoLogger.debug("COMPLETED ValidateSDNCResponse Process")
547 public void preProcessSDNCGetRequest(DelegateExecution execution){
548 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
549 execution.setVariable("prefix", Prefix)
550 msoLogger.trace("STARTED preProcessSDNCGetRequest Process")
552 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
554 String uuid = execution.getVariable('testReqId') // for junits
556 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
559 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
560 msoLogger.debug("callbackUrl:" + callbackUrl)
562 def vnfId = execution.getVariable('DCVFM_vnfId')
565 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
569 svcInstId = serviceInstanceId
571 // serviceOperation will be retrieved from "object-path" element
572 // in SDNC Assign Response for VNF
573 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
574 msoLogger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
576 String serviceOperation = ""
578 String data = utils.getNodeXml(response, "response-data")
579 msoLogger.debug("responseData: " + data)
580 serviceOperation = utils.getNodeText(data, "object-path")
581 msoLogger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
584 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
587 String SDNCGetRequest =
588 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
589 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
590 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
591 <sdncadapter:RequestHeader>
592 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
593 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
594 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
595 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
596 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
597 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
598 </sdncadapter:RequestHeader>
599 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
600 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
603 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
604 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
607 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
608 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
610 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
614 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
616 * @param execution The flow's execution instance.
618 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
619 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
620 'execution=' + execution.getId() +
622 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
623 msoLogger.trace('Entered ' + method)
626 def vnfId = execution.getVariable('DoCVNF_vnfId')
627 msoLogger.debug("VNF ID: " + vnfId)
629 String updateAAIGenericVnfRequest = """
630 <UpdateAAIGenericVnfRequest>
631 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
632 <orchestration-status>Active</orchestration-status>
633 </UpdateAAIGenericVnfRequest>
635 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
636 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
637 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
640 msoLogger.trace('Exited ' + method)
641 } catch (BpmnError e) {
643 } catch (Exception e) {
644 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
645 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())