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 org.onap.so.db.catalog.beans.HomingInstance
25 import static org.apache.commons.lang3.StringUtils.*
27 import org.camunda.bpm.engine.delegate.BpmnError
28 import org.camunda.bpm.engine.delegate.DelegateExecution
29 import org.onap.aai.domain.yang.GenericVnf
30 import org.onap.so.bpmn.common.scripts.AaiUtil
31 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
32 import org.onap.so.bpmn.common.scripts.ExceptionUtil
33 import org.onap.so.bpmn.common.scripts.MsoUtils
34 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
35 import org.onap.so.bpmn.common.scripts.VidUtils
36 import org.onap.so.bpmn.common.util.OofInfraUtils
37 import org.onap.so.bpmn.core.RollbackData
38 import org.onap.so.bpmn.core.UrnPropertiesReader
39 import org.onap.so.bpmn.core.WorkflowException
40 import org.onap.so.bpmn.core.domain.VnfResource
41 import org.onap.so.bpmn.core.json.JsonUtils
42 import org.onap.so.logger.MessageEnum
43 import org.onap.so.logger.MsoLogger
44 import org.onap.so.client.aai.AAIObjectType;
45 import org.onap.so.client.aai.AAIResourcesClient
46 import org.onap.so.client.aai.entities.AAIResultWrapper
47 import org.onap.so.client.aai.entities.uri.AAIResourceUri
48 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
49 import org.springframework.web.util.UriUtils
50 import org.json.JSONObject
54 * This class supports the DoCreateVnf building block subflow
55 * with the creation of a generic vnf for
59 class DoCreateVnf extends AbstractServiceTaskProcessor {
61 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnf.class);
62 String Prefix="DoCVNF_"
63 ExceptionUtil exceptionUtil = new ExceptionUtil()
64 JsonUtils jsonUtil = new JsonUtils()
65 VidUtils vidUtils = new VidUtils(this)
66 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
67 OofInfraUtils oofInfraUtils = new OofInfraUtils()
70 * This method gets and validates the incoming
76 public void preProcessRequest(DelegateExecution execution) {
77 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
78 execution.setVariable("prefix",Prefix)
79 msoLogger.debug("STARTED DoCreateVnf PreProcessRequest Process")
81 // DISABLE SDNC INTERACTION FOR NOW
82 execution.setVariable("SDNCInteractionEnabled", false)
89 def rollbackData = execution.getVariable("rollbackData")
90 if (rollbackData == null) {
91 rollbackData = new RollbackData()
94 String vnfModelInfo = execution.getVariable("vnfModelInfo")
95 String serviceModelInfo = execution.getVariable("serviceModelInfo")
97 String requestId = execution.getVariable("msoRequestId")
98 execution.setVariable("DoCVNF_requestId", requestId)
99 execution.setVariable("mso-request-id", requestId)
100 msoLogger.debug("Incoming Request Id is: " + requestId)
102 String serviceInstanceId = execution.getVariable("serviceInstanceId")
103 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
104 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
105 msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
107 String vnfType = execution.getVariable("vnfType")
108 execution.setVariable("DoCVNF_vnfType", vnfType)
109 msoLogger.debug("Incoming Vnf Type is: " + vnfType)
111 String vnfName = execution.getVariable("vnfName")
112 if (vnfName.equals("") || vnfName.equals("null")) {
113 AAIResourcesClient resourceClient = new AAIResourcesClient()
114 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId"))
115 if(resourceClient.exists(uri)){
116 exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")
121 execution.setVariable("DoCVNF_vnfName", vnfName)
122 msoLogger.debug("Incoming Vnf Name is: " + vnfName)
124 String serviceId = execution.getVariable("productFamilyId")
125 execution.setVariable("DoCVNF_serviceId", serviceId)
126 msoLogger.debug("Incoming Service Id is: " + serviceId)
128 String source = "VID"
129 execution.setVariable("DoCVNF_source", source)
130 rollbackData.put("VNF", "source", source)
131 msoLogger.debug("Incoming Source is: " + source)
133 String suppressRollback = execution.getVariable("disableRollback")
134 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
135 msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback)
137 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
138 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
139 msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
141 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
142 if (modelVersionId == null) {
145 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
146 msoLogger.debug("Incoming Version Id is: " + modelVersionId)
148 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
149 execution.setVariable("DoCVNF_modelVersion", modelVersion)
150 msoLogger.debug("Incoming Model Version is: " + modelVersion)
152 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
153 execution.setVariable("DoCVNF_modelName", modelName)
154 msoLogger.debug("Incoming Model Name is: " + modelName)
156 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
157 if (modelCustomizationId == null) {
158 modelCustomizationId = ""
160 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
161 msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
163 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
164 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
165 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
166 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
168 String tenantId = execution.getVariable("tenantId")
169 execution.setVariable("DoCVNF_tenantId", tenantId)
170 rollbackData.put("VNF", "tenantId", tenantId)
171 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
173 String globalSubscriberId = execution.getVariable("globalSubscriberId")
174 if (globalSubscriberId == null) {
175 globalSubscriberId = ""
177 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
178 msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
180 String sdncVersion = execution.getVariable("sdncVersion")
181 if (sdncVersion == null) {
184 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
185 msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
187 //For Completion Handler & Fallout Handler
189 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
190 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
191 <action>CREATE</action>
192 <source>${MsoUtils.xmlEscape(source)}</source>
195 execution.setVariable("DoCVNF_requestInfo", requestInfo)
196 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
197 String orchStatus = "Created"
198 execution.setVariable("DoCVNF_orchStatus", orchStatus)
200 //TODO: Equipment Role - Should come from SDN-C Response in 1702
201 String equipmentRole = " "
202 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
203 String vnfId = execution.getVariable("testVnfId") // for junits
205 vnfId = execution.getVariable("vnfId")
206 if (isBlank(vnfId)) {
207 vnfId = UUID.randomUUID().toString()
208 msoLogger.debug("Generated Vnf Id is: " + vnfId)
211 execution.setVariable("DoCVNF_vnfId", vnfId)
213 // Setting for Sub Flow Calls
214 execution.setVariable("DoCVNF_type", "generic-vnf")
215 execution.setVariable("GENGS_type", "service-instance")
217 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
218 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
219 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
220 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
221 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
223 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
224 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
225 msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
227 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
228 String nfRole = vnfResource.getNfRole()
230 execution.setVariable("DoCVNF_nfRole", nfRole)
231 msoLogger.debug("NF Role is: " + nfRole)
233 String nfNamingCode = vnfResource.getNfNamingCode()
234 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
235 msoLogger.debug("NF Naming Code is: " + nfNamingCode)
237 String nfType = vnfResource.getNfType()
238 execution.setVariable("DoCVNF_nfType", nfType)
239 msoLogger.debug("NF Type is: " + nfType)
241 String nfFunction = vnfResource.getNfFunction()
242 execution.setVariable("DoCVNF_nfFunction", nfFunction)
243 msoLogger.debug("NF Function is: " + nfFunction)
247 HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
248 if (homingInstance != null) {
249 execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
250 rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
251 msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
252 homingInstance.getCloudRegionId())
254 } catch (Exception exception) {
255 msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
257 msoLogger.debug("Could not find homing information for service instance error: " + exception)
260 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
261 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
262 rollbackData.put("VNF", "rollbackVnfCreate", "false")
264 execution.setVariable("rollbackData", rollbackData)
267 msoLogger.debug("Rethrowing MSOWorkflowException")
270 msoLogger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
271 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
274 msoLogger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
278 * Gets the service instance from aai
280 public void getServiceInstance(DelegateExecution execution) {
282 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
284 AAIResourcesClient resourceClient = new AAIResourcesClient()
285 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
287 if(resourceClient.exists(uri)){
288 Map<String, String> keys = uri.getURIKeys()
289 execution.setVariable("globalCustomerId", keys.get("global-customer-id"))
290 execution.setVariable("serviceType", keys.get("service-type"))
291 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
294 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
297 }catch(BpmnError e) {
299 }catch(Exception ex) {
300 String msg = "Exception in getServiceInstance. " + ex.getMessage()
302 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
306 private Object getVariableEnforced(DelegateExecution execution, String name){
307 Object enforced = execution.getVariable(name)
314 public void createGenericVnf (DelegateExecution execution) {
315 execution.setVariable("prefix",Prefix)
316 msoLogger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
319 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
320 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
321 if (vnfName == null) {
322 vnfName = "sdncGenerated"
323 msoLogger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
325 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
326 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
327 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
328 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
329 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
330 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
331 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
332 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
333 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
334 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
335 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
337 //Get Service Instance Info
338 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
340 String globalCustId = execution.getVariable("globalCustomerId")
341 String serviceType = execution.getVariable("serviceType")
343 Map<String, String> payload = new LinkedHashMap<>();
344 payload.put("vnf-id", vnfId);
345 payload.put("vnf-name", vnfName);
346 payload.put("service-id", serviceId);
347 payload.put("vnf-type", vnfType);
348 payload.put("prov-status", "PREPROV");
349 payload.put("orchestration-status", orchStatus);
350 payload.put("model-invariant-id", modelInvariantId);
351 payload.put("model-version-id", modelVersionId);
352 payload.put("model-customization-id", modelCustomizationId);
353 payload.put("nf-type", nfType);
354 payload.put("nf-role", nfRole);
355 payload.put("nf-function", nfFunction);
356 payload.put("nf-naming-code", nfNamingCode);
358 AAIResourcesClient resourceClient = new AAIResourcesClient();
359 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
360 resourceClient.create(uri, payload)
362 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
363 resourceClient.connect(uri, siUri)
365 }catch(Exception ex) {
366 msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex)
367 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
369 msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
372 public void postProcessCreateGenericVnf (DelegateExecution execution) {
373 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
374 execution.setVariable("prefix",Prefix)
376 msoLogger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
379 String vnfId = execution.getVariable("DoCVNF_vnfId")
380 def rollbackData = execution.getVariable("rollbackData")
381 rollbackData.put("VNF", "vnfId", vnfId)
382 rollbackData.put("VNF", "rollbackVnfCreate", "true")
383 execution.setVariable("rollbackData", rollbackData)
384 }catch(Exception ex) {
385 msoLogger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
386 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
388 msoLogger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
392 public void preProcessSDNCAssignRequest(DelegateExecution execution){
393 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
394 execution.setVariable("prefix", Prefix)
395 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
396 def vnfId = execution.getVariable("DoCVNF_vnfId")
397 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
398 msoLogger.debug("NEW VNF ID: " + vnfId)
403 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
405 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
406 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
407 msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
410 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCAssignRequest" , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
411 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
413 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
416 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
417 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
418 'execution=' + execution.getId() +
420 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
421 msoLogger.trace('Entered ' + method)
422 execution.setVariable("prefix", Prefix)
423 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
425 String vnfId = execution.getVariable("DoCVNF_vnfId")
426 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
428 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
430 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
431 msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
434 msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
435 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
437 msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process")
440 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
442 String uuid = execution.getVariable('testReqId') // for junits
444 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
446 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
447 def requestId = execution.getVariable("DoCVNF_requestId")
448 def serviceId = execution.getVariable("DoCVNF_serviceId")
449 def vnfType = execution.getVariable("DoCVNF_vnfType")
450 def vnfName = execution.getVariable("DoCVNF_vnfName")
451 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
452 String vnfNameString = ""
453 if (vnfName != null) {
454 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
456 def tenantId = execution.getVariable("DoCVNF_tenantId")
457 def source = execution.getVariable("DoCVNF_source")
458 def vnfId = execution.getVariable("DoCVNF_vnfId")
459 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
460 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
461 def serviceModelInfo = execution.getVariable("serviceModelInfo")
462 def vnfModelInfo = execution.getVariable("vnfModelInfo")
463 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
464 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
465 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
466 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
468 String sdncVNFParamsXml = ""
470 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
471 sdncVNFParamsXml = buildSDNCParamsXml(execution)
473 sdncVNFParamsXml = ""
477 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
478 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
479 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
480 <sdncadapter:RequestHeader>
481 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
482 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
483 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
484 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
485 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
486 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
487 </sdncadapter:RequestHeader>
488 <sdncadapterworkflow:SDNCRequestData>
489 <request-information>
490 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
491 <request-action>CreateVnfInstance</request-action>
492 <source>${MsoUtils.xmlEscape(source)}</source>
496 </request-information>
497 <service-information>
498 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
499 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
500 ${serviceEcompModelInformation}
501 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
502 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
503 </service-information>
505 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
506 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
507 ${vnfEcompModelInformation}
511 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
512 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
515 </sdncadapterworkflow:SDNCRequestData>
516 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
518 msoLogger.debug("sdncRequest: " + sdncRequest)
522 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
523 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
524 execution.setVariable("prefix",Prefix)
525 msoLogger.debug("STARTED ValidateSDNCResponse Process")
527 WorkflowException workflowException = execution.getVariable("WorkflowException")
528 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
530 msoLogger.debug("workflowException: " + workflowException)
532 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
533 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
535 msoLogger.debug("SDNCResponse: " + response)
537 String sdncResponse = response
538 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
539 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
540 if(method.equals("get")){
541 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
542 String data = utils.getNodeXml(topologyGetResponse, "response-data")
543 msoLogger.debug("topologyGetResponseData: " + data)
544 String vnfName = utils.getNodeText(data, "vnf-name")
545 msoLogger.debug("vnfName received from SDNC: " + vnfName)
546 execution.setVariable("vnfName", vnfName)
547 execution.setVariable("DoCVNF_vnfName", vnfName)
549 def rollbackData = execution.getVariable("rollbackData")
550 if (method.equals("assign")) {
551 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
553 else if (method.equals("activate")) {
554 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
556 execution.setVariable("rollbackData", rollbackData)
560 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
561 throw new BpmnError("MSOWorkflowException")
563 msoLogger.debug("COMPLETED ValidateSDNCResponse Process")
566 public void preProcessSDNCGetRequest(DelegateExecution execution){
567 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
568 execution.setVariable("prefix", Prefix)
569 msoLogger.trace("STARTED preProcessSDNCGetRequest Process")
571 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
573 String uuid = execution.getVariable('testReqId') // for junits
575 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
578 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
579 msoLogger.debug("callbackUrl:" + callbackUrl)
581 def vnfId = execution.getVariable('DCVFM_vnfId')
584 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
588 svcInstId = serviceInstanceId
590 // serviceOperation will be retrieved from "object-path" element
591 // in SDNC Assign Response for VNF
592 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
593 msoLogger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
595 String serviceOperation = ""
597 String data = utils.getNodeXml(response, "response-data")
598 msoLogger.debug("responseData: " + data)
599 serviceOperation = utils.getNodeText(data, "object-path")
600 msoLogger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
603 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
606 String SDNCGetRequest =
607 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
608 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
609 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
610 <sdncadapter:RequestHeader>
611 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
612 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
613 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
614 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
615 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
616 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
617 </sdncadapter:RequestHeader>
618 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
619 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
622 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
623 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
626 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
627 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
629 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
633 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
635 * @param execution The flow's execution instance.
637 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
638 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
639 'execution=' + execution.getId() +
641 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
642 msoLogger.trace('Entered ' + method)
645 def vnfId = execution.getVariable('DoCVNF_vnfId')
646 msoLogger.debug("VNF ID: " + vnfId)
648 String updateAAIGenericVnfRequest = """
649 <UpdateAAIGenericVnfRequest>
650 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
651 <orchestration-status>Active</orchestration-status>
652 </UpdateAAIGenericVnfRequest>
654 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
655 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
656 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
659 msoLogger.trace('Exited ' + method)
660 } catch (BpmnError e) {
662 } catch (Exception e) {
663 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
664 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())