2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.scripts
25 import org.onap.so.db.catalog.beans.HomingInstance
27 import static org.apache.commons.lang3.StringUtils.*
29 import org.camunda.bpm.engine.delegate.BpmnError
30 import org.camunda.bpm.engine.delegate.DelegateExecution
31 import org.onap.aai.domain.yang.GenericVnf
32 import org.onap.so.bpmn.common.scripts.AaiUtil
33 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
34 import org.onap.so.bpmn.common.scripts.ExceptionUtil
35 import org.onap.so.bpmn.common.scripts.MsoUtils
36 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
37 import org.onap.so.bpmn.common.scripts.VidUtils
38 import org.onap.so.bpmn.common.util.OofInfraUtils
39 import org.onap.so.bpmn.core.RollbackData
40 import org.onap.so.bpmn.core.UrnPropertiesReader
41 import org.onap.so.bpmn.core.WorkflowException
42 import org.onap.so.bpmn.core.domain.VnfResource
43 import org.onap.so.bpmn.core.json.JsonUtils
44 import org.onap.so.logger.MessageEnum
45 import org.onap.so.logger.MsoLogger
46 import org.slf4j.Logger
47 import org.slf4j.LoggerFactory
48 import org.onap.so.client.aai.AAIObjectType;
49 import org.onap.so.client.aai.AAIResourcesClient
50 import org.onap.so.client.aai.entities.AAIResultWrapper
51 import org.onap.so.client.aai.entities.uri.AAIResourceUri
52 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
53 import org.springframework.web.util.UriUtils
54 import org.json.JSONObject
58 * This class supports the DoCreateVnf building block subflow
59 * with the creation of a generic vnf for
63 class DoCreateVnf extends AbstractServiceTaskProcessor {
65 private static final Logger logger = LoggerFactory.getLogger( DoCreateVnf.class);
66 String Prefix="DoCVNF_"
67 ExceptionUtil exceptionUtil = new ExceptionUtil()
68 JsonUtils jsonUtil = new JsonUtils()
69 VidUtils vidUtils = new VidUtils(this)
70 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
71 OofInfraUtils oofInfraUtils = new OofInfraUtils()
74 * This method gets and validates the incoming
80 public void preProcessRequest(DelegateExecution execution) {
81 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
82 execution.setVariable("prefix",Prefix)
83 logger.debug("STARTED DoCreateVnf PreProcessRequest Process")
85 // DISABLE SDNC INTERACTION FOR NOW
86 execution.setVariable("SDNCInteractionEnabled", false)
93 def rollbackData = execution.getVariable("rollbackData")
94 if (rollbackData == null) {
95 rollbackData = new RollbackData()
98 String vnfModelInfo = execution.getVariable("vnfModelInfo")
99 String serviceModelInfo = execution.getVariable("serviceModelInfo")
101 String requestId = execution.getVariable("msoRequestId")
102 execution.setVariable("DoCVNF_requestId", requestId)
103 execution.setVariable("mso-request-id", requestId)
104 logger.debug("Incoming Request Id is: " + requestId)
106 String serviceInstanceId = execution.getVariable("serviceInstanceId")
107 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
108 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
109 logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
111 String vnfType = execution.getVariable("vnfType")
112 execution.setVariable("DoCVNF_vnfType", vnfType)
113 logger.debug("Incoming Vnf Type is: " + vnfType)
115 String vnfName = execution.getVariable("vnfName")
116 if (vnfName.equals("") || vnfName.equals("null")) {
117 AAIResourcesClient resourceClient = new AAIResourcesClient()
118 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId"))
119 if(resourceClient.exists(uri)){
120 exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")
125 execution.setVariable("DoCVNF_vnfName", vnfName)
126 logger.debug("Incoming Vnf Name is: " + vnfName)
128 String serviceId = execution.getVariable("productFamilyId")
129 execution.setVariable("DoCVNF_serviceId", serviceId)
130 logger.debug("Incoming Service Id is: " + serviceId)
132 String source = "VID"
133 execution.setVariable("DoCVNF_source", source)
134 rollbackData.put("VNF", "source", source)
135 logger.debug("Incoming Source is: " + source)
137 String suppressRollback = execution.getVariable("disableRollback")
138 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
139 logger.debug("Incoming Suppress Rollback is: " + suppressRollback)
141 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
142 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
143 logger.debug("Incoming Invariant Id is: " + modelInvariantId)
145 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
146 if (modelVersionId == null) {
149 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
150 logger.debug("Incoming Version Id is: " + modelVersionId)
152 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
153 execution.setVariable("DoCVNF_modelVersion", modelVersion)
154 logger.debug("Incoming Model Version is: " + modelVersion)
156 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
157 execution.setVariable("DoCVNF_modelName", modelName)
158 logger.debug("Incoming Model Name is: " + modelName)
160 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
161 if (modelCustomizationId == null) {
162 modelCustomizationId = ""
164 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
165 logger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
167 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
168 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
169 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
170 logger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
172 String tenantId = execution.getVariable("tenantId")
173 execution.setVariable("DoCVNF_tenantId", tenantId)
174 rollbackData.put("VNF", "tenantId", tenantId)
175 logger.debug("Incoming Tenant Id is: " + tenantId)
177 String globalSubscriberId = execution.getVariable("globalSubscriberId")
178 if (globalSubscriberId == null) {
179 globalSubscriberId = ""
181 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
182 logger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
184 String sdncVersion = execution.getVariable("sdncVersion")
185 if (sdncVersion == null) {
188 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
189 logger.debug("Incoming Sdnc Version is: " + sdncVersion)
191 //For Completion Handler & Fallout Handler
193 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
194 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
195 <action>CREATE</action>
196 <source>${MsoUtils.xmlEscape(source)}</source>
199 execution.setVariable("DoCVNF_requestInfo", requestInfo)
200 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
201 String orchStatus = "Created"
202 execution.setVariable("DoCVNF_orchStatus", orchStatus)
204 //TODO: Equipment Role - Should come from SDN-C Response in 1702
205 String equipmentRole = " "
206 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
207 String vnfId = execution.getVariable("testVnfId") // for junits
209 vnfId = execution.getVariable("vnfId")
210 if (isBlank(vnfId)) {
211 vnfId = UUID.randomUUID().toString()
212 logger.debug("Generated Vnf Id is: " + vnfId)
215 execution.setVariable("DoCVNF_vnfId", vnfId)
217 // Setting for Sub Flow Calls
218 execution.setVariable("DoCVNF_type", "generic-vnf")
219 execution.setVariable("GENGS_type", "service-instance")
221 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
222 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
223 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
224 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
225 MsoLogger.ErrorCode.UnknownError.getValue());
226 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
228 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
229 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
230 logger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
232 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
233 String nfRole = vnfResource.getNfRole()
235 execution.setVariable("DoCVNF_nfRole", nfRole)
236 logger.debug("NF Role is: " + nfRole)
238 String nfNamingCode = vnfResource.getNfNamingCode()
239 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
240 logger.debug("NF Naming Code is: " + nfNamingCode)
242 String nfType = vnfResource.getNfType()
243 execution.setVariable("DoCVNF_nfType", nfType)
244 logger.debug("NF Type is: " + nfType)
246 String nfFunction = vnfResource.getNfFunction()
247 execution.setVariable("DoCVNF_nfFunction", nfFunction)
248 logger.debug("NF Function is: " + nfFunction)
252 HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
253 if (homingInstance != null) {
254 execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
255 rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
256 logger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
257 homingInstance.getCloudRegionId())
259 } catch (Exception exception) {
260 logger.debug("Could not find homing information for service instance: " + serviceInstanceId +
262 logger.debug("Could not find homing information for service instance error: " + exception)
265 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
266 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
267 rollbackData.put("VNF", "rollbackVnfCreate", "false")
269 execution.setVariable("rollbackData", rollbackData)
272 logger.debug("Rethrowing MSOWorkflowException")
275 logger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
276 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
279 logger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
283 * Gets the service instance from aai
285 public void getServiceInstance(DelegateExecution execution) {
287 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
289 AAIResourcesClient resourceClient = new AAIResourcesClient()
290 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
292 if(resourceClient.exists(uri)){
293 Map<String, String> keys = uri.getURIKeys()
294 execution.setVariable("globalCustomerId", keys.get("global-customer-id"))
295 execution.setVariable("serviceType", keys.get("service-type"))
296 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
299 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
302 }catch(BpmnError e) {
304 }catch(Exception ex) {
305 String msg = "Exception in getServiceInstance. " + ex.getMessage()
307 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
311 private Object getVariableEnforced(DelegateExecution execution, String name){
312 Object enforced = execution.getVariable(name)
319 public void createGenericVnf (DelegateExecution execution) {
320 execution.setVariable("prefix",Prefix)
321 logger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
324 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
325 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
326 if (vnfName == null) {
327 vnfName = "sdncGenerated"
328 logger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
330 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
331 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
332 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
333 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
334 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
335 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
336 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
337 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
338 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
339 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
340 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
342 //Get Service Instance Info
343 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
345 String globalCustId = execution.getVariable("globalCustomerId")
346 String serviceType = execution.getVariable("serviceType")
348 Map<String, String> payload = new LinkedHashMap<>();
349 payload.put("vnf-id", vnfId);
350 payload.put("vnf-name", vnfName);
351 payload.put("service-id", serviceId);
352 payload.put("vnf-type", vnfType);
353 payload.put("prov-status", "PREPROV");
354 payload.put("orchestration-status", orchStatus);
355 payload.put("model-invariant-id", modelInvariantId);
356 payload.put("model-version-id", modelVersionId);
357 payload.put("model-customization-id", modelCustomizationId);
358 payload.put("nf-type", nfType);
359 payload.put("nf-role", nfRole);
360 payload.put("nf-function", nfFunction);
361 payload.put("nf-naming-code", nfNamingCode);
363 AAIResourcesClient resourceClient = new AAIResourcesClient();
364 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
365 resourceClient.create(uri, payload)
367 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
368 resourceClient.connect(uri, siUri)
370 }catch(Exception ex) {
371 logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex)
372 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
374 logger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
377 public void postProcessCreateGenericVnf (DelegateExecution execution) {
378 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
379 execution.setVariable("prefix",Prefix)
381 logger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
384 String vnfId = execution.getVariable("DoCVNF_vnfId")
385 def rollbackData = execution.getVariable("rollbackData")
386 rollbackData.put("VNF", "vnfId", vnfId)
387 rollbackData.put("VNF", "rollbackVnfCreate", "true")
388 execution.setVariable("rollbackData", rollbackData)
389 }catch(Exception ex) {
390 logger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
391 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
393 logger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
397 public void preProcessSDNCAssignRequest(DelegateExecution execution){
398 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
399 execution.setVariable("prefix", Prefix)
400 logger.trace("STARTED preProcessSDNCAssignRequest")
401 def vnfId = execution.getVariable("DoCVNF_vnfId")
402 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
403 logger.debug("NEW VNF ID: " + vnfId)
408 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
410 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
411 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
412 logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
415 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
416 "Exception Occured Processing preProcessSDNCAssignRequest", "BPMN",
417 MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
418 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
420 logger.trace("COMPLETED preProcessSDNCAssignRequest")
423 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
424 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
425 'execution=' + execution.getId() +
427 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
428 logger.trace('Entered ' + method)
429 execution.setVariable("prefix", Prefix)
430 logger.trace("STARTED preProcessSDNCActivateRequest Process")
432 String vnfId = execution.getVariable("DoCVNF_vnfId")
433 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
435 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
437 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
438 logger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
441 logger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
442 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
444 logger.trace("COMPLETED preProcessSDNCActivateRequest Process")
447 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
449 String uuid = execution.getVariable('testReqId') // for junits
451 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
453 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
454 def requestId = execution.getVariable("DoCVNF_requestId")
455 def serviceId = execution.getVariable("DoCVNF_serviceId")
456 def vnfType = execution.getVariable("DoCVNF_vnfType")
457 def vnfName = execution.getVariable("DoCVNF_vnfName")
458 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
459 String vnfNameString = ""
460 if (vnfName != null) {
461 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
463 def tenantId = execution.getVariable("DoCVNF_tenantId")
464 def source = execution.getVariable("DoCVNF_source")
465 def vnfId = execution.getVariable("DoCVNF_vnfId")
466 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
467 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
468 def serviceModelInfo = execution.getVariable("serviceModelInfo")
469 def vnfModelInfo = execution.getVariable("vnfModelInfo")
470 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
471 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
472 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
473 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
475 String sdncVNFParamsXml = ""
477 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
478 sdncVNFParamsXml = buildSDNCParamsXml(execution)
480 sdncVNFParamsXml = ""
484 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
485 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
486 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
487 <sdncadapter:RequestHeader>
488 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
489 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
490 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
491 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
492 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
493 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
494 </sdncadapter:RequestHeader>
495 <sdncadapterworkflow:SDNCRequestData>
496 <request-information>
497 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
498 <request-action>CreateVnfInstance</request-action>
499 <source>${MsoUtils.xmlEscape(source)}</source>
503 </request-information>
504 <service-information>
505 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
506 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
507 ${serviceEcompModelInformation}
508 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
509 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
510 </service-information>
512 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
513 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
514 ${vnfEcompModelInformation}
518 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
519 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
522 </sdncadapterworkflow:SDNCRequestData>
523 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
525 logger.debug("sdncRequest: " + sdncRequest)
529 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
530 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
531 execution.setVariable("prefix",Prefix)
532 logger.debug("STARTED ValidateSDNCResponse Process")
534 WorkflowException workflowException = execution.getVariable("WorkflowException")
535 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
537 logger.debug("workflowException: " + workflowException)
539 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
540 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
542 logger.debug("SDNCResponse: " + response)
544 String sdncResponse = response
545 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
546 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
547 if(method.equals("get")){
548 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
549 String data = utils.getNodeXml(topologyGetResponse, "response-data")
550 logger.debug("topologyGetResponseData: " + data)
551 String vnfName = utils.getNodeText(data, "vnf-name")
552 logger.debug("vnfName received from SDNC: " + vnfName)
553 execution.setVariable("vnfName", vnfName)
554 execution.setVariable("DoCVNF_vnfName", vnfName)
556 def rollbackData = execution.getVariable("rollbackData")
557 if (method.equals("assign")) {
558 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
560 else if (method.equals("activate")) {
561 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
563 execution.setVariable("rollbackData", rollbackData)
567 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
568 throw new BpmnError("MSOWorkflowException")
570 logger.debug("COMPLETED ValidateSDNCResponse Process")
573 public void preProcessSDNCGetRequest(DelegateExecution execution){
574 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
575 execution.setVariable("prefix", Prefix)
576 logger.trace("STARTED preProcessSDNCGetRequest Process")
578 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
580 String uuid = execution.getVariable('testReqId') // for junits
582 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
585 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
586 logger.debug("callbackUrl:" + callbackUrl)
588 def vnfId = execution.getVariable('DCVFM_vnfId')
591 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
595 svcInstId = serviceInstanceId
597 // serviceOperation will be retrieved from "object-path" element
598 // in SDNC Assign Response for VNF
599 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
600 logger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
602 String serviceOperation = ""
604 String data = utils.getNodeXml(response, "response-data")
605 logger.debug("responseData: " + data)
606 serviceOperation = utils.getNodeText(data, "object-path")
607 logger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
610 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
613 String SDNCGetRequest =
614 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
615 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
616 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
617 <sdncadapter:RequestHeader>
618 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
619 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
620 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
621 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
622 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
623 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
624 </sdncadapter:RequestHeader>
625 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
626 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
629 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
630 logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
633 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
634 "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN",
635 MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
636 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
638 logger.trace("COMPLETED preProcessSDNCGetRequest Process")
642 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
644 * @param execution The flow's execution instance.
646 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
647 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
648 'execution=' + execution.getId() +
650 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
651 logger.trace('Entered ' + method)
654 def vnfId = execution.getVariable('DoCVNF_vnfId')
655 logger.debug("VNF ID: " + vnfId)
657 String updateAAIGenericVnfRequest = """
658 <UpdateAAIGenericVnfRequest>
659 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
660 <orchestration-status>Active</orchestration-status>
661 </UpdateAAIGenericVnfRequest>
663 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
664 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
665 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
668 logger.trace('Exited ' + method)
669 } catch (BpmnError e) {
671 } catch (Exception e) {
672 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
673 "Caught exception in " + method, "BPMN",
674 MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
675 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())